Adding multiple markers with infowindows (Google Maps API)

后端 未结 6 1188
别跟我提以往
别跟我提以往 2020-11-29 17:28

I\'m currently using the following code the place multiple markers on a Google Map using their API.

The problem I\'m having is with multiple infowindows not working

6条回答
  •  一向
    一向 (楼主)
    2020-11-29 18:26

        function addMarker(Latlng){ 
           marker = new google.maps.Marker({
                position: Latlng,
                icon:"myicon.jpg",
                map: map,
                animation: google.maps.Animation.DROP,
                title:"My tooltip"
            });
    
            //add marker
            marker.setMap(map);
    
            contentString = "

    Hello World

    "; marker.infowindow = new google.maps.InfoWindow({ content: contentString }); //add click event google.maps.event.addListener(marker, 'click', function(){ this.infowindow.open(map,this); }); } addMarker(some_lat_lang_value);

提交回复
热议问题