X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/96ac0fb728e205871b2a4ca6d2d9b7d82a4fd2db..558e05cf462354969535d6f227fc5bb24ff5c0a6:/app/assets/javascripts/leaflet.layers.js diff --git a/app/assets/javascripts/leaflet.layers.js b/app/assets/javascripts/leaflet.layers.js index 82efab506..3f577b532 100644 --- a/app/assets/javascripts/leaflet.layers.js +++ b/app/assets/javascripts/leaflet.layers.js @@ -14,7 +14,7 @@ L.OSM.layers = function (options) { var buttonContainer = $("
") .appendTo(baseSection); - var mapContainer = $("
") + var mapContainer = $("
") .appendTo(buttonContainer); var input = $("") @@ -29,7 +29,7 @@ L.OSM.layers = function (options) { map.whenReady(function () { var miniMap = L.map(mapContainer[0], { attributionControl: false, zoomControl: false, keyboard: false }) - .addLayer(new layer.constructor({ apikey: layer.options.apikey })); + .addLayer(new layer.constructor(layer.options)); miniMap.dragging.disable(); miniMap.touchZoom.disable(); @@ -61,18 +61,16 @@ L.OSM.layers = function (options) { input.on("click", function () { layers.forEach(function (other) { - if (other === layer) { - map.addLayer(other); - } else { + if (other !== layer) { map.removeLayer(other); } }); - map.fire("baselayerchange", { layer: layer }); + map.addLayer(layer); }); item.on("dblclick", toggle); - map.on("layeradd layerremove", function () { + map.on("baselayerchange", function () { input.prop("checked", map.hasLayer(layer)); }); }); @@ -121,10 +119,9 @@ L.OSM.layers = function (options) { } else { map.removeLayer(layer); } - map.fire("overlaylayerchange", { layer: layer }); }); - map.on("layeradd layerremove", function () { + map.on("overlayadd overlayremove", function () { input.prop("checked", map.hasLayer(layer)); });