Closed adam-jones-net closed 5 years ago
This took me ages to work out so I'm posting here to share as I don't believe this is documented anywhere on the gmaps3 official docs...
var infoWindows = []; var locations=[ {position:[123,456],content:'<h3>marker title 1</h3><p>msg text</p>/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<infoWindows.length;i++) { infoWindows[i].close(); } }
This took me ages to work out so I'm posting here to share as I don't believe this is documented anywhere on the gmaps3 official docs...