From 3cf3d888b28ae8d9c2697a9b1083f3d5997e3947 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 4 Oct 2012 19:35:06 -0700 Subject: [PATCH] Refactor mapParams to compose better with apiUrl --- app/assets/javascripts/index.js | 4 ++-- app/assets/javascripts/osm.js.erb | 10 +++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 75b3fa1a8..21d5366f3 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -33,7 +33,7 @@ $(document).ready(function () { } if (params.object) { - addObjectToMap({type: params.object_type, id: params.object_id}, params.object_zoom); + addObjectToMap(params.object, params.object_zoom); } handleResize(); @@ -73,7 +73,7 @@ $(document).ready(function () { var extents = unproj(map.getExtent()); var expiry = new Date(); - updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top, params.object_type, params.object_id); + updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top, params.object.type, params.object.id); expiry.setYear(expiry.getFullYear() + 10); $.cookie("_osm_location", [lonlat.lon, lonlat.lat, zoom, layers].join("|"), {expires: expiry}); diff --git a/app/assets/javascripts/osm.js.erb b/app/assets/javascripts/osm.js.erb index 22a1023b4..75562ad48 100644 --- a/app/assets/javascripts/osm.js.erb +++ b/app/assets/javascripts/osm.js.erb @@ -44,18 +44,14 @@ OSM = { } if (params.node || params.way || params.relation) { - mapParams.object = true; mapParams.object_zoom = true; if (params.node) { - mapParams.object_type = 'node'; - mapParams.object_id = parseInt(params.node); + mapParams.object = {type: 'node', id: parseInt(params.node)}; } else if (params.way) { - mapParams.object_type = 'way'; - mapParams.object_id = parseInt(params.way); + mapParams.object = {type: 'way', id: parseInt(params.way)}; } else if (params.relation) { - mapParams.object_type = 'relation'; - mapParams.object_id = parseInt(params.relation); + mapParams.object = {type: 'relation', id: parseInt(params.relation)}; } } -- 2.39.5