From 6353efe294573e1a727e3714bb543376ea7abbe2 Mon Sep 17 00:00:00 2001 From: Xaver Maierhofer Date: Tue, 31 May 2016 20:24:29 +0200 Subject: [PATCH] [TASK] Remove leaflet-providers Issues with loading configutation like copyright notice. Provide your complete configuration in config.json - example in ffrgb branch --- app.js | 2 -- bower.json | 1 - lib/map.js | 76 +++--------------------------------------------------- 3 files changed, 3 insertions(+), 76 deletions(-) diff --git a/app.js b/app.js index f2d4e3c..0e333dd 100644 --- a/app.js +++ b/app.js @@ -5,7 +5,6 @@ require.config({ paths: { "leaflet": "../bower_components/leaflet/dist/leaflet", "leaflet.label": "../bower_components/Leaflet.label/dist/leaflet.label", - "leaflet.providers": "../bower_components/leaflet-providers/leaflet-providers", "chroma-js": "../bower_components/chroma-js/chroma.min", "moment": "../bower_components/moment/min/moment.min", "moment.de": "../bower_components/moment/locale/de", @@ -17,7 +16,6 @@ require.config({ }, shim: { "leaflet.label": ["leaflet"], - "leaflet.providers": ["leaflet"], "moment.de": ["moment"], "tablesort": { exports: "Tablesort" diff --git a/bower.json b/bower.json index 99a54d2..40c7d81 100644 --- a/bower.json +++ b/bower.json @@ -20,7 +20,6 @@ "d3": "~3.5.17", "roboto-fontface": "~0.4.5", "virtual-dom": "~2.1.1", - "leaflet-providers": "~1.1.10", "rbush": "https://github.com/mourner/rbush.git#~1.4.3" }, "authors": [ diff --git a/lib/map.js b/lib/map.js index 6f6a49f..b70bd16 100644 --- a/lib/map.js +++ b/lib/map.js @@ -1,6 +1,6 @@ define(["map/clientlayer", "map/labelslayer", "leaflet", "moment", "locationmarker", "rbush", "helper", - "leaflet.label", "leaflet.providers", "moment.de"], + "leaflet.label", "moment.de"], function (ClientLayer, LabelsLayer, L, moment, LocationMarker, rbush, helper) { "use strict"; @@ -9,30 +9,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 ion-android-add shadow"); - - // L.DomEvent.disableClickPropagation(button) - // Click propagation isn't disabled as this causes problems with the - // location picking mode; instead propagation is stopped in onClick(). - L.DomEvent.addListener(button, "click", this.f, this); - - this.button = button; - - return button; - } - }); - var LocateButton = L.Control.extend({ options: { position: "bottomright" @@ -170,7 +146,6 @@ define(["map/clientlayer", "map/labelslayer", var map, userLocation; var layerControl; - var customLayers = {}; var baseLayers = {}; var locateUserButton = new LocateButton(function (d) { @@ -239,7 +214,6 @@ define(["map/clientlayer", "map/labelslayer", function showCoordinates(e) { router.gotoLocation(e.latlng); - // window.prompt("Koordinaten (Lat, Lng)", e.latlng.lat.toFixed(9) + ", " + e.latlng.lng.toFixed(9)) disableCoords(); } @@ -259,28 +233,6 @@ define(["map/clientlayer", "map/labelslayer", } } - function addLayer(layerName) { - if (layerName in baseLayers) { - return; - } - - if (layerName in customLayers) { - return; - } - - try { - var layer = L.tileLayer.provider(layerName); - layerControl.addBaseLayer(layer, layerName); - customLayers[layerName] = layer; - - if (helper.localStorageTest()) { - localStorage.setItem("map/customLayers", JSON.stringify(Object.keys(customLayers))); - } - } catch (e) { - console.error(e); - } - } - function contextMenuOpenLayerMenu() { document.querySelector(".leaflet-control-layers").classList.add("leaflet-control-layers-expanded"); } @@ -292,8 +244,8 @@ define(["map/clientlayer", "map/labelslayer", var layers = config.mapLayers.map(function (d) { return { - "name": d.name, - "layer": "url" in d ? L.tileLayer(d.url, d.config) : L.tileLayer.provider(d.name) + "name": d.name + "ak", + "layer": "url" in d ? L.tileLayer(d.url, d.config) : console.warn("Missing map url") }; }); @@ -311,31 +263,9 @@ define(["map/clientlayer", "map/labelslayer", addButton(locateUserButton); addButton(showCoordsPickerButton); - 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 (helper.localStorageTest()) { - var d = JSON.parse(localStorage.getItem("map/customLayers")); - - if (d) { - d.forEach(addLayer); - } - - d = JSON.parse(localStorage.getItem("map/selectedLayer")); - d = d && d.name in baseLayers ? baseLayers[d.name] : d && d.name in customLayers ? customLayers[d.name] : false; - - if (d) { - map.removeLayer(layers[0].layer); - map.addLayer(d); - } - } - var clientLayer = new ClientLayer({minZoom: 15}); clientLayer.addTo(map); clientLayer.setZIndex(5);