|
@@ -6,28 +6,6 @@ define(["map/clientlayer", "map/labelslayer",
|
|
|
zoomControl: false
|
|
|
}
|
|
|
|
|
|
- var AddLayerButton = L.Control.extend({
|
|
|
- options: {
|
|
|
- position: "bottomright"
|
|
|
- },
|
|
|
-
|
|
|
- initialize: function (f, options) {
|
|
|
- L.Util.setOptions(this, options)
|
|
|
- this.f = f
|
|
|
- },
|
|
|
-
|
|
|
- onAdd: function () {
|
|
|
- var button = L.DomUtil.create("button", "add-layer")
|
|
|
- button.textContent = ""
|
|
|
-
|
|
|
- L.DomEvent.disableClickPropagation(button)
|
|
|
- L.DomEvent.addListener(button, "click", this.f, this)
|
|
|
-
|
|
|
- this.button = button
|
|
|
-
|
|
|
- return button
|
|
|
- }
|
|
|
- })
|
|
|
|
|
|
var CoordsButton = L.Control.extend({
|
|
|
options: {
|
|
@@ -167,7 +145,6 @@ define(["map/clientlayer", "map/labelslayer",
|
|
|
|
|
|
var map, userLocation
|
|
|
var layerControl
|
|
|
- var customLayers = new Set()
|
|
|
var baseLayers = {}
|
|
|
|
|
|
var locateUserButton = new LocateButton(function (d) {
|
|
@@ -249,25 +226,6 @@ define(["map/clientlayer", "map/labelslayer",
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- function addLayer(layerName) {
|
|
|
- if (layerName in baseLayers)
|
|
|
- return
|
|
|
-
|
|
|
- if (customLayers.has(layerName))
|
|
|
- return
|
|
|
-
|
|
|
- try {
|
|
|
- var layer = L.tileLayer.provider(layerName)
|
|
|
- layerControl.addBaseLayer(layer, layerName)
|
|
|
- customLayers.add(layerName)
|
|
|
-
|
|
|
- if (localStorageTest())
|
|
|
- localStorage.setItem("map/customLayers", JSON.stringify(Array.from(customLayers)))
|
|
|
- } catch (e) {
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
var el = document.createElement("div")
|
|
|
el.classList.add("map")
|
|
|
|
|
@@ -293,22 +251,9 @@ define(["map/clientlayer", "map/labelslayer",
|
|
|
addButton(locateUserButton)
|
|
|
addButton(showCoordsButton)
|
|
|
|
|
|
- addButton(new AddLayerButton(function () {
|
|
|
- /*eslint no-alert:0*/
|
|
|
- var layerName = prompt("Leaflet Provider:")
|
|
|
- addLayer(layerName)
|
|
|
- }))
|
|
|
-
|
|
|
layerControl = L.control.layers(baseLayers, [], {position: "bottomright"})
|
|
|
layerControl.addTo(map)
|
|
|
|
|
|
- if (localStorageTest()) {
|
|
|
- var d = JSON.parse(localStorage.getItem("map/customLayers"))
|
|
|
-
|
|
|
- if (d)
|
|
|
- d.forEach(addLayer)
|
|
|
- }
|
|
|
-
|
|
|
var clientLayer = new ClientLayer({minZoom: 15})
|
|
|
clientLayer.addTo(map)
|
|
|
clientLayer.setZIndex(5)
|