updatelinks(centre.lon, centre.lat, 16, null, params.minlon, params.minlat, params.maxlon, params.maxlat);
} else {
- var url = "/api/" + OSM.API_VERSION + "/" + params.type + "/" + params.id;
-
- if (params.type != "node") {
- url += "/full";
- } else if (!params.visible) {
- var previous_version = params.version - 1;
- url += "/" + previous_version;
- }
-
$("#object_larger_map").hide();
$("#object_edit").hide();
- addObjectToMap(url, true, function(extent) {
+ var object = {type: params.type, id: params.id};
+
+ if (!params.visible) {
+ object.version = params.version - 1;
+ }
+
+ addObjectToMap(object, true, function(extent) {
$("#loading").hide();
$("#browse_map .geolink").show();
}
if (params.object) {
- var url = "/api/" + OSM.API_VERSION + "/" + params.object_type + "/" + params.object_id;
-
- if (params.object_type != "node") {
- url += "/full";
- }
-
- addObjectToMap(url, params.object_zoom);
+ addObjectToMap({type: params.object_type, id: params.object_id}, params.object_zoom);
}
handleResize();
return marker;
}
-function addObjectToMap(url, zoom, callback) {
+function addObjectToMap(object, zoom, callback) {
var layer = new OpenLayers.Layer.Vector("Objects", {
strategies: [
new OpenLayers.Strategy.Fixed()
],
protocol: new OpenLayers.Protocol.HTTP({
- url: url,
+ url: OSM.apiUrl(object),
format: new OpenLayers.Format.OSM()
}),
style: {
SERVER_URL: <%= SERVER_URL.to_json %>,
API_VERSION: <%= API_VERSION.to_json %>,
+ apiUrl: function (object) {
+ var url = "/api/" + OSM.API_VERSION + "/" + object.type + "/" + object.id;
+
+ if (object.type != "node") {
+ url += "/full";
+ } else if (object.version) {
+ url += "/" + object.version;
+ }
+
+ return url;
+ },
+
mapParams: function (search) {
var params = {}, mapParams = {}, loc;