leaflet-demo: use same #map= format as openstreetmap.org
This commit is contained in:
parent
4b9e06c4a8
commit
8b9bc50b82
@ -23,7 +23,7 @@
|
|||||||
<div id="map"></div>
|
<div id="map"></div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// permalink support: https://github.com/MarcChasse/leaflet.Permalink
|
// permalink support: based on https://github.com/MarcChasse/leaflet.Permalink
|
||||||
L.Permalink = {
|
L.Permalink = {
|
||||||
//gets the map center, zoom-level and rotation from the URL if present, else uses default values
|
//gets the map center, zoom-level and rotation from the URL if present, else uses default values
|
||||||
getMapLocation: function (zoom, center) {
|
getMapLocation: function (zoom, center) {
|
||||||
@ -31,15 +31,14 @@
|
|||||||
zoom = (zoom || zoom === 0) ? zoom : 18;
|
zoom = (zoom || zoom === 0) ? zoom : 18;
|
||||||
center = (center) ? center : [52.26869, -113.81034];
|
center = (center) ? center : [52.26869, -113.81034];
|
||||||
|
|
||||||
if (window.location.hash !== '') {
|
if (window.location.hash.startsWith('#map=')) {
|
||||||
var hash = window.location.hash.replace('#', '');
|
var parts = window.location.hash.substring(5).split('/');
|
||||||
var parts = hash.split(',');
|
if (parts.length >= 3) {
|
||||||
if (parts.length === 3) {
|
zoom = parseInt(parts[0]);
|
||||||
center = {
|
center = {
|
||||||
lat: parseFloat(parts[0]),
|
lat: parseFloat(parts[1]),
|
||||||
lng: parseFloat(parts[1])
|
lng: parseFloat(parts[2])
|
||||||
};
|
};
|
||||||
zoom = parseInt(parts[2].slice(0, -1), 10);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {zoom: zoom, center: center};
|
return {zoom: zoom, center: center};
|
||||||
@ -56,10 +55,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var center = map.getCenter();
|
var center = map.getCenter();
|
||||||
var hash = '#' +
|
var hash = '#map=' +
|
||||||
Math.round(center.lat * 100000) / 100000 + ',' +
|
map.getZoom() + '/' +
|
||||||
Math.round(center.lng * 100000) / 100000 + ',' +
|
Math.round(center.lat * 100000) / 100000 + '/' +
|
||||||
map.getZoom() + 'z';
|
Math.round(center.lng * 100000) / 100000
|
||||||
var state = {
|
var state = {
|
||||||
zoom: map.getZoom(),
|
zoom: map.getZoom(),
|
||||||
center: center
|
center: center
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user