So I'm using (https://mapbuildr.com/buildr) to make a map but no even with default settings and two markers this happens:
Click marker A, info window pops up. Click marker B, info window A stays up and info window B pops up. Example: https://jsfiddle.net/u4ejxnv8/
The part I am confused about is this doesn't happen on their site when demoing the map, it only happens after it is embedded into another site. I've tried in both Chrome and FF. Anyone see anything wrong with their code?
<script src='https://maps.googleapis.com/maps/api/js?key=&sensor=false&extension=.js'></script> <script> google.maps.event.addDomListener(window, 'load', init); var map; function init() { var mapOptions = { center: new google.maps.LatLng(53.558461,14.581546), zoom: 12, zoomControl: true, zoomControlOptions: { style: google.maps.ZoomControlStyle.DEFAULT, }, disableDoubleClickZoom: true, mapTypeControl: true, mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR, }, scaleControl: true, scrollwheel: true, panControl: true, streetViewControl: true, draggable : true, overviewMapControl: true, overviewMapControlOptions: { opened: false, }, mapTypeId: google.maps.MapTypeId.ROADMAP, } var mapElement = document.getElementById('test'); var map = new google.maps.Map(mapElement, mapOptions); var locations = [ ['test', 'undefined', 'undefined', 'undefined', 'undefined', 53.5520416, 14.572060800000031, 'https://mapbuildr.com/assets/img/markers/default.png'],['test2', 'undefined', 'undefined', 'undefined', 'undefined', 53.55148069132529, 14.558928704663117, 'https://mapbuildr.com/assets/img/markers/default.png'] ]; for (i = 0; i < locations.length; i++) { if (locations[i][1] =='undefined'){ description ='';} else { description = locations[i][1];} if (locations[i][2] =='undefined'){ telephone ='';} else { telephone = locations[i][2];} if (locations[i][3] =='undefined'){ email ='';} else { email = locations[i][3];} if (locations[i][4] =='undefined'){ web ='';} else { web = locations[i][4];} if (locations[i][7] =='undefined'){ markericon ='';} else { markericon = locations[i][7];} marker = new google.maps.Marker({ icon: markericon, position: new google.maps.LatLng(locations[i][5], locations[i][6]), map: map, title: locations[i][0], desc: description, tel: telephone, email: email, web: web }); if (web.substring(0, 7) != "http://") { link = "http://" + web; } else { link = web; } bindInfoWindow(marker, map, locations[i][0], description, telephone, email, web, link); } function bindInfoWindow(marker, map, title, desc, telephone, email, web, link) { var infoWindowVisible = (function () { var currentlyVisible = false; return function (visible) { if (visible !== undefined) { currentlyVisible = visible; } return currentlyVisible; }; }()); iw = new google.maps.InfoWindow(); google.maps.event.addListener(marker, 'click', function() { if (infoWindowVisible()) { iw.close(); infoWindowVisible(false); } else { var html= "<div style='color:#000;background-color:#fff;padding:5px;width:150px;'><h4>"+title+"</h4><p>"+desc+"<p><p>"+telephone+"<p><a href='mailto:"+email+"' >"+email+"<a><a href='"+link+"'' >"+web+"<a></div>"; iw = new google.maps.InfoWindow({content:html}); iw.open(map,marker); infoWindowVisible(true); } }); google.maps.event.addListener(iw, 'closeclick', function () { infoWindowVisible(false); }); } } </script> <style> #test { height:400px; width:550px; } .gm-style-iw * { display: block; width: 100%; } .gm-style-iw h4, .gm-style-iw p { margin: 0; padding: 0; } .gm-style-iw a { color: #4272db; } </style> <div id='test'></div>