X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/57e711d3434664568998946d90ffef0a5f948130..b8f126bcf6d53417d49b9cdd933714421fb8925c:/app/assets/javascripts/index.js diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 68f10ebc1..19e1f16de 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -19,7 +19,7 @@ $(document).ready(function () { map.attributionControl.setPrefix(''); - new L.Hash(map); + map.hash = L.hash(map); var layers = [ new L.OSM.Mapnik({ @@ -50,8 +50,11 @@ $(document).ready(function () { layers[0].addTo(map); - map.noteLayer = new L.LayerGroup({code: 'N'}); + 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(); @@ -81,8 +84,6 @@ $(document).ready(function () { L.OSM.share({ position: position, - getShortUrl: getShortUrl, - getUrl: getUrl, sidebar: sidebar, short: true }).addTo(map); @@ -100,24 +101,21 @@ $(document).ready(function () { map.markerLayer = L.layerGroup().addTo(map); if (!params.object_zoom) { - if (params.bbox) { - var bbox = L.latLngBounds([params.minlat, params.minlon], - [params.maxlat, params.maxlon]); - - map.fitBounds(bbox); - - if (params.box) { - L.rectangle(bbox, { - weight: 2, - color: '#e90', - fillOpacity: 0 - }).addTo(map); - } + if (params.bounds) { + map.fitBounds(params.bounds); } else { map.setView([params.lat, params.lon], params.zoom); } } + if (params.box) { + L.rectangle(params.box, { + weight: 2, + color: '#e90', + fillOpacity: 0 + }).addTo(map); + } + if (params.layers) { var foundLayer = false; for (var i = 0; i < layers.length; i++) { @@ -166,8 +164,8 @@ $(document).ready(function () { } initializeExport(map); - initializeBrowse(map); - initializeNotes(map); + initializeBrowse(map, params); + initializeNotes(map, params); }); function updateLocation() { @@ -179,6 +177,9 @@ function updateLocation() { var expiry = new Date(); expiry.setYear(expiry.getFullYear() + 10); $.cookie("_osm_location", cookieContent(this), { expires: expiry }); + + // Trigger hash update on layer changes. + this.hash.onMapMove(); } function setPositionLink(map) {