X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/c8fb5ad24c5751bd2d43b86e4359381d200af066..f9d714dfd36fa56ced4c0a99a6e59c945ff89cca:/app/assets/javascripts/index.js diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 029c0bfd1..19e1f16de 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -19,6 +19,8 @@ $(document).ready(function () { map.attributionControl.setPrefix(''); + map.hash = L.hash(map); + var layers = [ new L.OSM.Mapnik({ attribution: '', @@ -48,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(); @@ -79,8 +84,6 @@ $(document).ready(function () { L.OSM.share({ position: position, - getShortUrl: getShortUrl, - getUrl: getUrl, sidebar: sidebar, short: true }).addTo(map); @@ -98,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++) { @@ -164,8 +164,8 @@ $(document).ready(function () { } initializeExport(map); - initializeBrowse(map); - initializeNotes(map); + initializeBrowse(map, params); + initializeNotes(map, params); }); function updateLocation() { @@ -177,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) {