Skip to content

Commit 8a21aef

Browse files
argiloTheSkorm
authored andcommitted
Save & restore map coordinates and zoom
1 parent 1ab564f commit 8a21aef

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

js/sondehub.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -858,20 +858,30 @@ function clean_refresh(text, force, history_step) {
858858
}
859859

860860
function load() {
861+
coords = offline.get("mc");
862+
if (coords == null) {
863+
coords = [53.467511,-2.233894];
864+
}
865+
866+
zoomLevel = offline.get("mz");
867+
if (zoomLevel == null) {
868+
zoomLevel = 5;
869+
}
870+
861871
//initialize map object
862872
map = new L.map(document.getElementById('map'), {
863-
zoom: 5,
873+
zoom: zoomLevel,
864874
zoomControl: false,
865875
zoomAnimationThreshold: 0,
866876
zoomAnimation: true,
867877
markerZoomAnimation: false,
868-
center: [53.467511,-2.233894],
878+
center: coords,
869879
layers: baseMaps[selectedLayer],
870880
worldCopyJump: true,
871881
preferCanvas: true,
872882
});
873883

874-
map.setView([53.467511,-2.233894], 5, {animate: false});
884+
map.setView(coords, zoomLevel, {animate: false});
875885

876886
// fullscreen button
877887
map.addControl(new L.Control.Fullscreen({ position: 'bottomleft' }));
@@ -1012,6 +1022,10 @@ function load() {
10121022
lhash_update();
10131023
sidebar_update();
10141024
sub_to_nearby_sondes();
1025+
1026+
var latlng = map.getCenter();
1027+
offline.set("mc", [roundNumber(latlng.lat, 5), roundNumber(latlng.lng, 5)]);
1028+
offline.set("mz", map.getZoom());
10151029
});
10161030

10171031
map.on('baselayerchange', function (e) {

0 commit comments

Comments
 (0)