From 22e9eb39cce83fce141910c184ec8c5ecdf7e371 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Sat, 24 Nov 2012 13:07:23 -0400 Subject: [PATCH] Inject connection dependency in map --- js/iD/id.js | 10 ++++++---- js/iD/renderer/Map.js | 10 +--------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/js/iD/id.js b/js/iD/id.js index 849b50113..21aa6319f 100644 --- a/js/iD/id.js +++ b/js/iD/id.js @@ -4,8 +4,10 @@ var iD = function(container) { var m = container.append('div') .attr('id', 'map'); - var map = iD.Map(m.node()) - .setAPI('http://api06.dev.openstreetmap.org/api/0.6/'); + var connection = iD.Connection() + .url('http://api06.dev.openstreetmap.org/api/0.6/'); + + var map = iD.Map(m.node(), connection); var controller = iD.Controller(map); @@ -137,12 +139,12 @@ var iD = function(container) { if (oauth.authenticated()) { oauth.xhr({ method: 'GET', path: '/user/details' }, function(user_details) { var u = user_details.getElementsByTagName('user')[0]; - map.connection.user({ + connection.user({ display_name: u.attributes.display_name.nodeValue, id: u.attributes.id.nodeValue }); d3.select('.messages').text('logged in as ' + - map.connection.user().display_name); + connection.user().display_name); }); } }; diff --git a/js/iD/renderer/Map.js b/js/iD/renderer/Map.js index 38494cba1..2615ce1ec 100644 --- a/js/iD/renderer/Map.js +++ b/js/iD/renderer/Map.js @@ -1,4 +1,4 @@ -iD.Map = function(elem) { +iD.Map = function(elem, connection) { if (!iD.supported()) { elem.innerHTML = 'This editor is supported in Firefox, Chrome, Safari, Opera, ' + @@ -12,7 +12,6 @@ iD.Map = function(elem) { dimensions = { width: null, height: null }, dispatch = d3.dispatch('move', 'update'), history = iD.History(), - connection = iD.Connection(), inspector = iD.Inspector(), parent = d3.select(elem), selection = null, @@ -535,11 +534,6 @@ iD.Map = function(elem) { return map; } - function setAPI(x) { - connection.url(x); - return map; - } - function commit() { var modified = _.filter(history.graph().entities, function(e) { return e.modified; @@ -583,10 +577,8 @@ iD.Map = function(elem) { map.zoomIn = zoomIn; map.zoomOut = zoomOut; - map.connection = connection; map.projection = projection; map.setSize = setSize; - map.setAPI = setAPI; map.history = history; map.surface = surface;