How to set a popup on markers with Google Maps API?

后端 未结 4 440
小鲜肉
小鲜肉 2021-02-01 18:09

I have this code where I display and set all my markers. How can I add a popup with some information on markers with this code? I add \"i\" variable on text, but it sets on all

4条回答
  •  余生分开走
    2021-02-01 18:48

    var marker = new google.maps.Marker({
                  position: myLatLng,
                  ....
                  content: point[4]
              });
    google.maps.event.addListener(marker, 'click', function() {
                infowindow.setContent(this.content);
                infowindow.open(map, this);
              });
    

    Code inside loop. This worked for me perfectly.

提交回复
热议问题