Show all infowindows open

前端 未结 1 778
孤街浪徒
孤街浪徒 2021-01-22 04:36

I\'m trying to have custom infowindows float above markers, however I noticed that only one marker can be opened at any one time. Is there a workaround to this?

Here\'s

相关标签:
1条回答
  • 2021-01-22 05:30

    There is no limitation implicit to the Google Maps API v3 that makes only one InfowWindow available at a time. You need to write your code to do that. If you want an InfoWindow for each marker, make one.

    Some thing like (not tested):

    function createMarker(latlng, html) {
       var contentString = html;
        var infowindow = new google.maps.InfoWindow();
        var marker = new google.maps.Marker({
            position: latlng,
            map: map,
            zIndex: Math.round(latlng.lat()*-100000)<<5
            });
    
        google.maps.event.addListener(marker, 'click', function() {
            infowindow.setContent(contentString); 
            infowindow.open(map,marker);
            });
    }
    
    0 讨论(0)
提交回复
热议问题