43 lines
1.8 KiB
JavaScript
43 lines
1.8 KiB
JavaScript
$(document)
|
|
.ready(
|
|
function() {
|
|
var mapProp = {
|
|
center : new google.maps.LatLng(52.05, 19.45),
|
|
zoom : 6,
|
|
mapTypeId : google.maps.MapTypeId.ROADMAP
|
|
};
|
|
var map = new google.maps.Map(document
|
|
.getElementById("googleMapContainer"), mapProp);
|
|
|
|
var markers = JSON.parse(b64_to_utf8($('#googleMapMarkers')
|
|
.val()));
|
|
$.each(markers, function(index, m) {
|
|
var marker = new google.maps.Marker({
|
|
position : new google.maps.LatLng(m.lat, m.lng),
|
|
url : '/',
|
|
animation : google.maps.Animation.DROP,
|
|
customInfo : m.info,
|
|
title : m.title,
|
|
map : map
|
|
});
|
|
google.maps.event.addListener(marker, 'click',
|
|
markerClickFunction);
|
|
});
|
|
|
|
function markerClickFunction() {
|
|
infowindow = new google.maps.InfoWindow({
|
|
content : this.customInfo
|
|
});
|
|
infowindow.open(map, this);
|
|
closeInfoWindow(infowindow);
|
|
}
|
|
function closeInfoWindow(infoWindow) {
|
|
setTimeout(function() {
|
|
infoWindow.close();
|
|
}, 8000);
|
|
}
|
|
});
|
|
|
|
function b64_to_utf8(str) {
|
|
return decodeURIComponent(escape(window.atob(str)));
|
|
} |