Skip to content
Snippets Groups Projects
Commit c776989d authored by Anton Sarukhanov's avatar Anton Sarukhanov
Browse files

Half-ass solution to #8.

parent dde4846f
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@ var BusMap = {
zoomShowVehicles: 15,
stopZoom: 16,
vehicleMaxAge: 10,
locateOptions = { timeout: 3000, },
locateOptions: { timeout: 3000, },
};
/*
......@@ -426,7 +426,8 @@ BusMap.Map = function(opts) {
// Scaling: update what is displayed based on zoom level
function zoomShowHide() {
var zoom = that.leaflet.getZoom();
if (that.vehicleMarkersGroup) {
var got_vehicles = Object.keys(map.vehicleMarkers).length > 0;
if (got_vehicles && that.vehicleMarkersGroup) {
if (zoom >= BusMap.zoomShowVehicles
&& !(that.leaflet.hasLayer(that.vehicleMarkersGroup))) {
that.leaflet.addLayer(that.vehicleMarkersGroup);
......@@ -485,9 +486,15 @@ BusMap.Map = function(opts) {
// Go to zoom level and map center where vehicles are visible.
function goToVehicles() {
// TODO: this
var zoom = BusMap.zoomShowVehicles;
console.log("going to zoom " + zoom);
var veh_keys = Object.keys(that.vehicleMarkers);
if (veh_keys.length > 0) {
var ll = that.vehicleMarkers[veh_keys[0]].getLatLng();
} else {
var ll = that.leaflet.getCenter();
}
console.log("setView("+ll+","+zoom+")");
that.leaflet.setView(ll, zoom);
}
init();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment