X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/9bcd049c98eb09e0b822710448e64dd5c266c498..6adcce4e5d75fa21dea85742fa36ee3b97247b01:/app/assets/javascripts/index.js diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index a19a6a61e..d84b8ae24 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -48,15 +48,25 @@ $(document).ready(function () { code: "Q", keyid: "mapquest", name: I18n.t("javascripts.map.base.mapquest") + }), + new L.OSM.HOT({ + attribution: copyright + ". Tiles courtesy of Humanitarian OpenStreetMap Team", + code: "H", + keyid: "hot", + name: I18n.t("javascripts.map.base.hot") }) ]; function updateLayers(params) { var layerParam = params.layers || "M"; + var layersAdded = ""; for (var i = layers.length - 1; i >= 0; i--) { if (layerParam.indexOf(layers[i].options.code) >= 0) { map.addLayer(layers[i]); + layersAdded = layersAdded + layers[i].options.code; + } else if (i == 0 && layersAdded == "") { + map.addLayer(layers[i]); } else { map.removeLayer(layers[i]); } @@ -69,6 +79,12 @@ $(document).ready(function () { updateLayers(OSM.mapParams()); }); + map.on("baselayerchange", function (e) { + if (map.getZoom() > e.layer.options.maxZoom) { + map.setView(map.getCenter(), e.layer.options.maxZoom, { reset: true }); + } + }); + map.noteLayer = new L.LayerGroup(); map.noteLayer.options = {code: 'N'};