Close all info windows google maps API V3?

前端 未结 3 1106
[愿得一人]
[愿得一人] 2020-12-14 20:20

How do i get all info windows to close upon clikcing another pin or clicking the map in itself? I\'m using http://google-maps-utility-library-v3.googlecode.com/svn/trunk/in

3条回答
  •  被撕碎了的回忆
    2020-12-14 20:32

    In case anyone wants to do this in the context of gmaps3 jQuery wrapper...

    var infoWindows = [];
    var locations=[
        {position:[123,456],content:'

    marker title 1

    msg text

    /div>'} ] var map=$('#mapName').gmap3() .marker(locations) .infowindow(locations) .then(function (infowindow) { var map = this.get(0); var marker = this.get(1); marker.forEach(function(item,i){ item.addListener('click', function() { closeAllInfoWindows(); infowindow[i].open(map, item); infoWindows.push(infowindow[i]); }); }) }) .fit(); function closeAllInfoWindows() { for (var i=0;i

提交回复
热议问题