Revert "Extends Leaflet-fullhash properly"
This reverts commit 3a06009cba7e74600bb7a1ed0c511cfa8e1c7ffc.
This commit is contained in:
parent
d4c5ca67b9
commit
cc5da47cad
4 changed files with 3 additions and 74 deletions
|
|
@ -25,8 +25,7 @@
|
||||||
"leaflet.locatecontrol": "^0.60.0",
|
"leaflet.locatecontrol": "^0.60.0",
|
||||||
"font-awesome": "^4.7.0",
|
"font-awesome": "^4.7.0",
|
||||||
"bootstrap-select": "hugdx/bootstrap-select#patch-1",
|
"bootstrap-select": "hugdx/bootstrap-select#patch-1",
|
||||||
"leaflet-sidebar": "^0.1.9",
|
"leaflet-sidebar": "^0.1.9"
|
||||||
"leaflet-fullHash": "KoGor/leaflet-fullHash#master"
|
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"leaflet": {
|
"leaflet": {
|
||||||
|
|
@ -97,9 +96,6 @@
|
||||||
"css/font-awesome.css",
|
"css/font-awesome.css",
|
||||||
"fonts/*"
|
"fonts/*"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"leaflet-fullHash": {
|
|
||||||
"main": "leaflet-fullHash.js"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -263,12 +263,10 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
urlHash = new BR.Hash(map, mapLayers);
|
urlHash = new L.Hash(map, mapLayers, function() {
|
||||||
urlHash.additionalCb = function() {
|
|
||||||
var url = router.getUrl(routing.getWaypoints(), null);
|
var url = router.getUrl(routing.getWaypoints(), null);
|
||||||
return "&" + url.substr('brouter?'.length + 1);
|
return "&" + url.substr('brouter?'.length + 1);
|
||||||
};
|
}, onHashChangeCb);
|
||||||
urlHash.onHashChangeCb = onHashChangeCb;
|
|
||||||
routingOptions.on('update', urlHash.updateHash, urlHash);
|
routingOptions.on('update', urlHash.updateHash, urlHash);
|
||||||
nogos.on('update', urlHash.updateHash, urlHash);
|
nogos.on('update', urlHash.updateHash, urlHash);
|
||||||
// waypoint add, move, delete (but last)
|
// waypoint add, move, delete (but last)
|
||||||
|
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
||||||
BR.Hash = L.hash.extend({
|
|
||||||
|
|
||||||
formatHash: function(map) {
|
|
||||||
var center = map.getCenter(),
|
|
||||||
zoom = map.getZoom(),
|
|
||||||
precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2)),
|
|
||||||
layers = [];
|
|
||||||
|
|
||||||
//console.log(this.options);
|
|
||||||
var options = this.options;
|
|
||||||
//Check active layers
|
|
||||||
for(var key in options) {
|
|
||||||
if (options.hasOwnProperty(key)) {
|
|
||||||
if (map.hasLayer(options[key])) {
|
|
||||||
layers.push(key);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
var url = "#" + [zoom,
|
|
||||||
center.lat.toFixed(precision),
|
|
||||||
center.lng.toFixed(precision),
|
|
||||||
layers.join("-")
|
|
||||||
].join("/");
|
|
||||||
|
|
||||||
if (this.additionalCb != null) {
|
|
||||||
var additional = this.additionalCb();
|
|
||||||
if (additional != null) {
|
|
||||||
url += additional;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return url;
|
|
||||||
},
|
|
||||||
|
|
||||||
update: function() {
|
|
||||||
var hash = location.hash;
|
|
||||||
if (hash === this.lastHash) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var parsed = this.parseHash(hash);
|
|
||||||
if (parsed) {
|
|
||||||
this.movingMap = true;
|
|
||||||
|
|
||||||
this.map.setView(parsed.center, parsed.zoom);
|
|
||||||
var layers = parsed.layers,
|
|
||||||
options = this.options,
|
|
||||||
that = this;
|
|
||||||
//Add/remove layers
|
|
||||||
this.map.eachLayer(function(layer) {
|
|
||||||
that.map.removeLayer(layer);
|
|
||||||
});
|
|
||||||
|
|
||||||
layers.forEach(function(element, index, array) {
|
|
||||||
//console.log(options[element]);
|
|
||||||
that.map.addLayer(options[element]);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.movingMap = false;
|
|
||||||
} else {
|
|
||||||
this.onMapMove(this.map);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue