X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/1a51f2187127f7376e2118b5a4ced49123b0504a..53e4d600e712dea988028a12f68927c3400a6901:/app/assets/javascripts/osm.js.erb diff --git a/app/assets/javascripts/osm.js.erb b/app/assets/javascripts/osm.js.erb index eb5ce64f3..a3022f9ae 100644 --- a/app/assets/javascripts/osm.js.erb +++ b/app/assets/javascripts/osm.js.erb @@ -1,7 +1,6 @@ OSM = { -<% if defined?(PIWIK_LOCATION) and defined?(PIWIK_SITE) %> - PIWIK_LOCATION: <%= PIWIK_LOCATION.to_json %>, - PIWIK_SITE: <%= PIWIK_SITE.to_json %>, +<% if defined?(PIWIK) %> + PIWIK: <%= PIWIK.to_json %>, <% end %> MAX_REQUEST_AREA: <%= MAX_REQUEST_AREA.to_json %>, @@ -13,7 +12,7 @@ OSM = { apiUrl: function (object) { var url = "/api/" + OSM.API_VERSION + "/" + object.type + "/" + object.id; - if (object.type != "node") { + if (object.type === "way" || object.type === "relation") { url += "/full"; } else if (object.version) { url += "/" + object.version; @@ -39,7 +38,7 @@ OSM = { }, mapParams: function (search) { - var params = OSM.params(search), mapParams = {}, bounds, loc; + var params = OSM.params(search), mapParams = {}, bounds, loc, match; if (params.mlon && params.mlat) { mapParams.marker = true; @@ -47,7 +46,11 @@ OSM = { mapParams.mlat = parseFloat(params.mlat); } - if (params.node || params.way || params.relation) { + match = window.location.pathname.match(/\/browse\/(node|way|relation|changeset)\/(\d+)/); + if (match) { + mapParams.object_zoom = true; + mapParams.object = {type: match[1], id: parseInt(match[2])}; + } else if (params.node || params.way || params.relation || params.note) { mapParams.object_zoom = true; if (params.node) { @@ -59,6 +62,13 @@ OSM = { } } + match = window.location.pathname.match(/\/browse\/note\/(\d+)/); + if (match) { + mapParams.note = parseInt(match[1]); + } else if (params.note) { + mapParams.note = parseInt(params.note); + } + if (params.bbox) { params.bbox = params.bbox.split(','); bounds = L.latLngBounds( @@ -74,10 +84,6 @@ OSM = { parseFloat(params.maxlon)]); } - if (params.box === 'yes') { - mapParams.box = bounds; - } - var hash = OSM.parseHash(location.hash); // Decide on a map starting position. Various ways of doing this. @@ -124,10 +130,6 @@ OSM = { mapParams.layers = hash.layers || (loc && loc[3]) || ''; - if (params.note) { - mapParams.note = parseInt(params.note); - } - var scale = parseFloat(params.scale); if (scale > 0) { mapParams.zoom = Math.log(360.0 / (scale * 512.0)) / Math.log(2.0);