X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/9bcd049c98eb09e0b822710448e64dd5c266c498..d359cd70f1527b372b71c2f927e3f45fb0fcf509:/app/assets/javascripts/index.js diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index a19a6a61e..ef553f328 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,16 +79,18 @@ $(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'}; map.dataLayer = new L.OSM.DataLayer(null); map.dataLayer.options.code = 'D'; - $("#sidebar").on("opened closed", function () { - map.invalidateSize(); - }); - var position = $('html').attr('dir') === 'rtl' ? 'topleft' : 'topright'; L.OSM.zoom({position: position}) @@ -146,14 +158,6 @@ $(document).ready(function () { } } - if (params.box) { - L.rectangle(params.box, { - weight: 2, - color: '#e90', - fillOpacity: 0 - }).addTo(map); - } - if (params.marker) { marker.setLatLng([params.mlat, params.mlon]).addTo(map); } @@ -199,6 +203,8 @@ $(document).ready(function () { initializeExport(map); initializeBrowse(map, params); initializeNotes(map, params); + + if ('undefined' !== typeof initializeChangesets) initializeChangesets(map); }); function updateLocation() {