google maps api infobox plugin and multiple markers

前端 未结 3 1127
南笙
南笙 2020-12-08 17:47

How can I create multiple markers with different content when using infobox plugin http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/examples/infobox-ba

3条回答
  •  既然无缘
    2020-12-08 18:16

    For infobox toggle onclick replace :

    google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function() {
            newMarkers[i].infobox.open(theMap, this);
            theMap.panTo(markerData[i].latLng);
        }
    })(marker, i));
    

    By :

    google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function() {
            for ( h = 0; h < newMarkers.length; h++ ) {
                newMarkers[h].infobox.close();
            }
            newMarkers[i].infobox.open(theMap, this);
            theMap.panTo(markerData[i].latLng);
        }
    })(marker, i));
    

提交回复
热议问题