From ba9cc703d7c9c224a5635d38fd1408d9d1e7a738 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Sun, 19 Apr 2015 16:54:35 +0200 Subject: [PATCH] map: save bounds on drag end store on resetview --- lib/map.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/map.js b/lib/map.js index e9572c5..a6e1468 100644 --- a/lib/map.js +++ b/lib/map.js @@ -122,6 +122,7 @@ define(["map/clientlayer", "map/labelslayer", var self = this var barycenter var groupOnline, groupOffline, groupNew, groupLost, groupLines + var savedBounds var map, userLocation var layerControl @@ -134,6 +135,10 @@ define(["map/clientlayer", "map/labelslayer", disableTracking() }) + function saveView() { + savedBounds = map.getBounds() + } + function enableTracking() { map.locate({watch: true, enableHighAccuracy: true, @@ -199,6 +204,7 @@ define(["map/clientlayer", "map/labelslayer", map.on("locationfound", locationFound) map.on("locationerror", locationError) + map.on("dragend", saveView) map.addControl(locateUserButton) @@ -280,6 +286,8 @@ define(["map/clientlayer", "map/labelslayer", if (!nopanzoom) if (m) goto(m) + else if (savedBounds) + map.fitBounds(savedBounds) else resetZoom() }