bounds-fit if &fit=1

closes #48
This commit is contained in:
Jan-Piet Mens
2015-09-30 16:55:18 +02:00
parent 0ffe9711a6
commit 4cc7913817

View File

@@ -1,13 +1,17 @@
var map;
var do_fit = false;
var markers = {};
var livemarkers = true;
function initialize() {
var lat = 50.098280;
var lon = 10.187189;
var params = getSearchParameters();
var center = new google.maps.LatLng(lat,lon);
do_fit = (params.fit) ? true : false;
mapOptions = {
center: center,
zoom: 3, // 9,
@@ -30,6 +34,23 @@ function clog(upd, id, s) {
console.log(upd + ": " + ident + " " + s);
}
/* http://stackoverflow.com/questions/5448545/ */
function getSearchParameters() {
var prmstr = window.location.search.substr(1);
return prmstr != null && prmstr != "" ? transformToAssocArray(prmstr) : {};
}
function transformToAssocArray( prmstr ) {
var params = {};
var prmarr = prmstr.split("&");
for ( var i = 0; i < prmarr.length; i++) {
var tmparr = prmarr[i].split("=");
params[tmparr[0]] = tmparr[1];
}
return params;
}
/*
* Close all the infowindows in the `markers' object, and then open the
* infowindow in the specified marker.
@@ -123,7 +144,9 @@ function map_marker(loc)
markers[id] = m;
}
fitbounds();
if (do_fit) {
fitbounds();
}
}
google.maps.event.addDomListener(window, 'load', initialize);