Google Maps API Multiple Markers with Infowindows

前端 未结 5 1669
挽巷
挽巷 2020-11-30 17:45

I am trying to add multiple markers each with its own infowindow that comes up when clicked on. I am having trouble with getting the infowindows coming up, when I try it eit

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-30 18:09

    Here is the code snippet which will work for sure. You can visit below link for working jsFiddle and explainantion in detail. How to locate multiple addresses on google maps with perfect zoom

    var infowindow = new google.maps.InfoWindow();  
    google.maps.event.addListener(marker, 'mouseover', (function(marker) {  
               return function() {  
                   var content = address;  
                   infowindow.setContent(content);  
                   infowindow.open(map, marker);  
               }  
             })(marker));  
    

提交回复
热议问题