From cc5da47cad18573bdbfb1b1e54562e6852e5bbbf Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Mon, 24 Apr 2017 14:57:19 +0200 Subject: [PATCH] Revert "Extends Leaflet-fullhash properly" This reverts commit 3a06009cba7e74600bb7a1ed0c511cfa8e1c7ffc. --- bower.json | 6 +-- js/index.js | 6 +-- js/plugin/Hash.js | 65 ------------------------- old.js => js/plugin/leaflet-fullHash.js | 0 4 files changed, 3 insertions(+), 74 deletions(-) delete mode 100644 js/plugin/Hash.js rename old.js => js/plugin/leaflet-fullHash.js (100%) diff --git a/bower.json b/bower.json index 1e2ef5e..b243d15 100644 --- a/bower.json +++ b/bower.json @@ -25,8 +25,7 @@ "leaflet.locatecontrol": "^0.60.0", "font-awesome": "^4.7.0", "bootstrap-select": "hugdx/bootstrap-select#patch-1", - "leaflet-sidebar": "^0.1.9", - "leaflet-fullHash": "KoGor/leaflet-fullHash#master" + "leaflet-sidebar": "^0.1.9" }, "overrides": { "leaflet": { @@ -97,9 +96,6 @@ "css/font-awesome.css", "fonts/*" ] - }, - "leaflet-fullHash": { - "main": "leaflet-fullHash.js" } } } diff --git a/js/index.js b/js/index.js index 03498e6..9d7ffde 100644 --- a/js/index.js +++ b/js/index.js @@ -263,12 +263,10 @@ } }; - urlHash = new BR.Hash(map, mapLayers); - urlHash.additionalCb = function() { + urlHash = new L.Hash(map, mapLayers, function() { var url = router.getUrl(routing.getWaypoints(), null); return "&" + url.substr('brouter?'.length + 1); - }; - urlHash.onHashChangeCb = onHashChangeCb; + }, onHashChangeCb); routingOptions.on('update', urlHash.updateHash, urlHash); nogos.on('update', urlHash.updateHash, urlHash); // waypoint add, move, delete (but last) diff --git a/js/plugin/Hash.js b/js/plugin/Hash.js deleted file mode 100644 index 64a3967..0000000 --- a/js/plugin/Hash.js +++ /dev/null @@ -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); - } - }, - -}); \ No newline at end of file diff --git a/old.js b/js/plugin/leaflet-fullHash.js similarity index 100% rename from old.js rename to js/plugin/leaflet-fullHash.js