Google Maps API Multiple Markers with Infowindows

前端 未结 5 1656
挽巷
挽巷 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:18

    If you also want to bind closing of infowindow to some event, try something like this

    google.maps.event.addListener(marker,'click', (function(marker,content,infowindow){ 
        return function() {
            infowindow.setContent(content);
            infowindow.open(map,marker);
            windows.push(infowindow)
            google.maps.event.addListener(map,'click', function(){ 
                infowindow.close();
            }); 
        };
    })(marker,content,infowindow)); 
    

提交回复
热议问题