diff --git a/index.html b/index.html index 2e9910b63..ed093fa42 100755 --- a/index.html +++ b/index.html @@ -91,31 +91,27 @@ map.setZoom(18); map.setCentre({ lat: 40.796, lon: -74.691 }); - // Initialise controller - var controller = new iD.Controller(map); - map.setController(controller); - // ---------------------------------------------------- // Data is loaded and app ready to go // Set initial controllerState - controller.setState(new iD.controller.edit.NoSelection()); + map.controller.setState(new iD.controller.edit.NoSelection()); // ---------------------------------------------------- // Mode button handlers $('#add-place').click(function() { - controller.setState(new iD.controller.shape.NoSelection('node')); + map.controller.setState(new iD.controller.shape.NoSelection('node')); }); $('#add-road').click(function() { - controller.setState(new iD.controller.shape.NoSelection('way')); + map.controller.setState(new iD.controller.shape.NoSelection('way')); }); $('#add-area').click(function() { - controller.setState(new iD.controller.shape.NoSelection()); + map.controller.setState(new iD.controller.shape.NoSelection()); }); $('#undo').click(function() { - controller.undoStack.undo(); + map.controller.undoStack.undo(); map.updateUIs(true, true); }); diff --git a/js/iD/Controller.js b/js/iD/Controller.js index bfc091d79..fee9dbf15 100755 --- a/js/iD/Controller.js +++ b/js/iD/Controller.js @@ -2,7 +2,7 @@ // Controller base class if (typeof iD === 'undefined') iD = {}; -iD.Controller = function(map) { +iD.Controller = function() { var controller = {}, state = null; diff --git a/js/iD/renderer/Map.js b/js/iD/renderer/Map.js index 8a5553f3f..25ecf03da 100755 --- a/js/iD/renderer/Map.js +++ b/js/iD/renderer/Map.js @@ -11,6 +11,8 @@ iD.renderer.Map = function(obj) { this.width = obj.width ? obj.width : 800; this.height = obj.height ? obj.height : 400; + this.controller = iD.Controller(); + // Initialise variables this.uis = {}; @@ -69,9 +71,6 @@ iD.renderer.Map = function(obj) { // Create group for elastic band this.elastic = this.container.append('g'); - // Make draggable - this.surface.on('onclick', _.bind(this.clickSurface, this)); - this.redraw(); }; @@ -81,7 +80,6 @@ iD.renderer.Map.prototype = { surface: null, //
.surface containing the rendering container: null, // root-level group within the surface connection: null, // data store - controller: null, // UI controller tilegroup: null, // group within container for adding bitmap tiles tilebaseURL: 'http://ecn.t0.tiles.virtualearth.net/tiles/a$quadkey.jpeg?g=587&mkt=en-gb&n=z', // Bing imagery URL @@ -96,11 +94,6 @@ iD.renderer.Map.prototype = { elastic: null, // Group for drawing elastic band ruleset: null, // map style - setController:function(controller) { - // summary: Set the controller that will handle events on the map (e.g. mouse clicks). - this.controller = controller; - }, - download: _.debounce(function() { // summary: Ask the connection to download data for the current viewport. this.connection.loadFromAPI(this.extent(), _.bind(this.updateUIs, this)); @@ -315,12 +308,5 @@ iD.renderer.Map.prototype = { this.redraw(); return this; }, - - setCenter: function(loc) { this.setCentre(loc); }, - - clickSurface:function(e) { - // summary: Handle a click on an empty area of the map. - if (this.dragged && e.timeStamp==this.dragtime) { return; } - this.controller.entityMouseEvent(e,null); - } + setCenter: function(loc) { this.setCentre(loc); } };