Skip to content

Commit

Permalink
Use leaflet.restoreview.js plugin to save and restore last user's map…
Browse files Browse the repository at this point in the history
… position between sessions (#48)
  • Loading branch information
bagage committed Jul 21, 2016
1 parent 42d04e5 commit 66abb83
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 63 deletions.
6 changes: 5 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"Leaflet.EasyButton": "*",
"bootbox": "~4.4.0",
"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": {
"leaflet": {
Expand Down Expand Up @@ -79,6 +80,9 @@
},
"url-search-params": {
"main": "build/url-search-params.js"
},
"Leaflet.RestoreView": {
"main": "leaflet.restoreview.js"
}
},
"resolutions": {
Expand Down
12 changes: 6 additions & 6 deletions dist/brouter-web.css

Large diffs are not rendered by default.

95 changes: 48 additions & 47 deletions dist/brouter-web.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/brouter-web.js.map

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions js/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
BRouter web - web client for BRouter bike routing engine
Licensed under the MIT license.
*/

Expand All @@ -11,7 +11,7 @@

function initMap() {
L.Icon.Default.imagePath = 'dist/images';

var osmAttribution = '&copy; <a target="_blank" href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
var maxZoom = 19;

Expand Down Expand Up @@ -74,10 +74,11 @@
});

map = new L.Map('map', {
center: new L.LatLng(50.99, 9.86),
zoom: 6,
worldCopyJump: true
});
if (!map.restoreView()) {
map.setView([50.99, 9.86], 6);
}
map.attributionControl.addAttribution(
'<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 '
Expand Down Expand Up @@ -121,9 +122,9 @@
var search,
router,
routing,
routesLayer,
routingOptions,
nogos,
routesLayer,
routingOptions,
nogos,
stats,
itinerary,
elevation,
Expand Down Expand Up @@ -182,7 +183,7 @@
function requestUpdate(updatable) {
var track = routing.toPolyline(),
segments = routing.getSegments();

updatable.update(track, segments);
}

Expand Down

0 comments on commit 66abb83

Please sign in to comment.