Use leaflet.restoreview.js plugin to save and restore last user's map position between sessions (#48)

This commit is contained in:
Gautier Pelloux-Prayer 2016-07-21 18:44:37 +02:00
parent 42d04e52c2
commit 66abb83c60
5 changed files with 69 additions and 63 deletions

View file

@ -20,7 +20,8 @@
"Leaflet.EasyButton": "*", "Leaflet.EasyButton": "*",
"bootbox": "~4.4.0", "bootbox": "~4.4.0",
"seiyria-bootstrap-slider": "~4.8.1", "seiyria-bootstrap-slider": "~4.8.1",
"url-search-params": "~0.5.0" "url-search-params": "~0.5.0",
"Leaflet.RestoreView": "makinacorpus/Leaflet.RestoreView#master"
}, },
"overrides": { "overrides": {
"leaflet": { "leaflet": {
@ -79,6 +80,9 @@
}, },
"url-search-params": { "url-search-params": {
"main": "build/url-search-params.js" "main": "build/url-search-params.js"
},
"Leaflet.RestoreView": {
"main": "leaflet.restoreview.js"
} }
}, },
"resolutions": { "resolutions": {

12
dist/brouter-web.css vendored

File diff suppressed because one or more lines are too long

93
dist/brouter-web.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -74,10 +74,11 @@
}); });
map = new L.Map('map', { map = new L.Map('map', {
center: new L.LatLng(50.99, 9.86),
zoom: 6,
worldCopyJump: true worldCopyJump: true
}); });
if (!map.restoreView()) {
map.setView([50.99, 9.86], 6);
}
map.attributionControl.addAttribution( map.attributionControl.addAttribution(
'<a href="http://brouter.de/brouter" target="_blank">BRouter</a> &copy; Arndt Brenschede, ' '<a href="http://brouter.de/brouter" target="_blank">BRouter</a> &copy; Arndt Brenschede, '
+ 'routing + map data &copy; <a target="_blank" href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors ' + 'routing + map data &copy; <a target="_blank" href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors '