Google Maps: Auto close open InfoWindows?

前端 未结 12 685
终归单人心
终归单人心 2020-12-02 05:30

On my site, I\'m using Google Maps API v3 to place house markers on the map.

The InfoWindows stay open unless you explicitly click the close icon. Meaning, you can h

12条回答
  •  Happy的楠姐
    2020-12-02 06:17

    var contentString = "Location: " + results[1].formatted_address;    
    google.maps.event.addListener(marker,'click', (function(){ 
        infowindow.close();
        infowindow = new google.maps.InfoWindow({
            content: contentString
        });
        infowindow.open(map, marker);
    }));
    

提交回复
热议问题