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 %>,
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;
},
mapParams: function (search) {
- var params = OSM.params(search), mapParams = {}, bounds, loc;
+ var params = OSM.params(search), mapParams = {}, loc, match;
if (params.mlon && params.mlat) {
mapParams.marker = true;
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) {
}
}
- if (params.bbox) {
- params.bbox = params.bbox.split(',');
- bounds = L.latLngBounds(
- [parseFloat(params.bbox[1]),
- parseFloat(params.bbox[0])],
- [parseFloat(params.bbox[3]),
- parseFloat(params.bbox[2])]);
- } else if (params.minlon && params.minlat && params.maxlon && params.maxlat) {
- bounds = L.latLngBounds(
- [parseFloat(params.minlat),
- parseFloat(params.minlon)],
- [parseFloat(params.maxlat),
- parseFloat(params.maxlon)]);
- }
-
- if (params.box === 'yes') {
- mapParams.box = bounds;
+ match = window.location.pathname.match(/\/browse\/note\/(\d+)/);
+ if (match) {
+ mapParams.note = parseInt(match[1]);
+ } else if (params.note) {
+ mapParams.note = parseInt(params.note);
}
var hash = OSM.parseHash(location.hash);
mapParams.lat = hash.center.lat;
mapParams.zoom = hash.zoom;
mapParams.object_zoom = false;
- } else if (bounds) {
- mapParams.lon = bounds.getCenter().lng; // Not used by main map, but
- mapParams.lat = bounds.getCenter().lat; // are used by iD/Potlatch.
- mapParams.bounds = bounds;
- mapParams.object_zoom = false;
} else if (params.lon && params.lat) {
mapParams.lon = parseFloat(params.lon);
mapParams.lat = parseFloat(params.lat);
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);