How to put a infowindow on polyline in Google Maps v3?

前端 未结 3 1182
情歌与酒
情歌与酒 2021-01-12 05:51

I want to know how to show infowindow on polyline in using Google Maps Api V3? and to appear in the middle of the polyline ?!

3条回答
  •  终归单人心
    2021-01-12 06:50

    Firstly you will need to calculate the middle/center of the polyline. This has been discussed and answered here; https://stackoverflow.com/a/9090409/787921

    Then you will have to open the infowindow;

    var infowindow = new google.maps.InfoWindow({
                 content: "infowindow text content"});
    infowindow.setPosition(midLatLng);
    infowindow.open(map);
    

提交回复
热议问题