experimental: live map fits bounds to all devices

closes #46
This commit is contained in:
Jan-Piet Mens
2015-09-30 11:07:00 +02:00
parent cb0c5038c2
commit 03ce11217b

View File

@@ -41,6 +41,15 @@ function refreshmarkers(m) {
m['infowindow'].open(map, m);
}
function fitbounds() {
var bounds = new google.maps.LatLngBounds();
for (var k in markers) {
bounds.extend(markers[k].getPosition());
}
map.setCenter(bounds.getCenter()); /* Center to geometric center of all markers */
map.fitBounds(bounds);
}
/*
* `loc' is a location object obtained via Websockets from the recorder
*/
@@ -112,6 +121,8 @@ function map_marker(loc)
markers[id] = m;
}
fitbounds();
}
google.maps.event.addDomListener(window, 'load', initialize);