function loadScript(src, callback) { var s, r, t; r = false; s = document.createElement('script'); s.type = 'text/javascript'; s.src = src; s.onload = s.onreadystatechange = function() { //console.log( this.readyState ); //uncomment this line to see which ready states are called. if ( !r && (!this.readyState || this.readyState == 'complete') ) { r = true; callback(); } }; t = document.getElementsByTagName('script')[0]; t.parentNode.insertBefore(s, t); } loadMap = function (){ $('
').insertAfter('.breadcrumbs'); window.locations = new Array(); $('ul.accordion li.accordion-navigation').each(function(){ locations.push({ lat: $(this).find('.lat').val(), lng: $(this).find('.lng').val(), html: $(this).find('.content').html() }); }); window.map = new google.maps.Map(document.getElementById('map'), { clickable: true, zoomControl: true, scrollwheel: true, mapTypeControl: true, disableDefaultUI: true, zoom: 5, center: new google.maps.LatLng(51.151786, 10.415039) }); var infoWindows = new Array(); var markers = new Array(); $.each(locations, function (key, location) { markers.push(new google.maps.Marker({ position: new google.maps.LatLng(location.lat, location.lng), map: map, //icon: BB.storeIcon, //title: location.title })); infoWindows.push(new google.maps.InfoWindow({ content: location.html, maxWidth: 400 })); markers[key].addListener('click', function() { $.each(infoWindows, function(key2, infowindow){ infowindow.close(); }); infoWindows[key].open(map, markers[key]); }); }); } loadScript("https://maps.google.com/maps/api/js?key=AIzaSyBui3Y-sroMjQ1hwzoi2KurASd8WGGPM58",loadMap);