From f527a4f6fde9dd8469e52766a5bd7b4aed932615 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Wed, 12 Dec 2012 17:22:45 -0500 Subject: [PATCH 1/4] Complete bindings for roads and areas. Fixes #180 --- js/id/modes/draw_area.js | 27 +++++++++++++++++++++++---- js/id/modes/draw_road.js | 24 ++++++++++++++++++++---- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/js/id/modes/draw_area.js b/js/id/modes/draw_area.js index 3bfe5b947..ae5925ea0 100644 --- a/js/id/modes/draw_area.js +++ b/js/id/modes/draw_area.js @@ -63,7 +63,7 @@ iD.modes.DrawArea = function(wayId) { controller.enter(iD.modes.Browse()); } - function del() { + function backspace() { d3.event.preventDefault(); history.replace( @@ -80,10 +80,27 @@ iD.modes.DrawArea = function(wayId) { } } + function del() { + d3.event.preventDefault(); + history.replace(iD.actions.DeleteWay(wayId)); + controller.enter(iD.modes.Browse()); + } + + function ret() { + d3.event.preventDefault(); + history.replace( + iD.actions.DeleteNode(node.id), + iD.actions.AddWayNode(way.id, tailId, -1), + 'added to an area'); + controller.enter(iD.modes.Browse()); + } + map.surface.on('mousemove.drawarea', mousemove); map.surface.on('click.drawarea', click); - map.keybinding().on('⎋.drawarea', esc); - map.keybinding().on('⌫.drawarea', del); + map.keybinding().on('⎋.drawarea', esc) + .on('⌫.drawarea', backspace) + .on('delete.drawarea', del) + .on('↩.drawarea', ret); }; mode.exit = function() { @@ -93,7 +110,9 @@ iD.modes.DrawArea = function(wayId) { .on('mousemove.drawarea', null) .on('click.drawarea', null); mode.map.keybinding().on('⎋.drawarea', null) - .on('⌫.drawarea', null); + .on('⌫.drawarea', null) + .on('delete.drawarea', null) + .on('↩.drawarea', null); window.setTimeout(function() { mode.map.dblclickEnable(true); }, 1000); diff --git a/js/id/modes/draw_road.js b/js/id/modes/draw_road.js index c78ff913d..463e97f76 100644 --- a/js/id/modes/draw_road.js +++ b/js/id/modes/draw_road.js @@ -81,7 +81,7 @@ iD.modes.DrawRoad = function(wayId, direction) { controller.enter(iD.modes.Browse()); } - function del() { + function backspace() { d3.event.preventDefault(); history.replace( @@ -96,8 +96,22 @@ iD.modes.DrawRoad = function(wayId, direction) { } } - map.keybinding().on('⎋.drawroad', esc); - map.keybinding().on('⌫.drawroad', del); + function del() { + d3.event.preventDefault(); + history.replace(iD.actions.DeleteWay(wayId)); + controller.enter(iD.modes.Browse()); + } + + function ret() { + d3.event.preventDefault(); + history.replace(iD.actions.DeleteNode(node.id)); + controller.enter(iD.modes.Browse()); + } + + map.keybinding().on('⎋.drawroad', esc) + .on('⌫.drawroad', backspace) + .on('delete.drawroad', del) + .on('↩.drawroad', ret); }; mode.exit = function() { @@ -108,7 +122,9 @@ iD.modes.DrawRoad = function(wayId, direction) { .on('mousemove.drawroad', null) .on('click.drawroad', null); mode.map.keybinding().on('⎋.drawroad', null) - .on('⌫.drawroad', null); + .on('⌫.drawroad', null) + .on('delete.drawroad', null) + .on('↩.drawroad', null); window.setTimeout(function() { mode.map.dblclickEnable(true); }, 1000); From dc4c5dcb3f22e5d18418034f8bf38ff69e634caa Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Wed, 12 Dec 2012 17:45:20 -0500 Subject: [PATCH 2/4] Fix way dragging distortion. Fixes #258 --- js/id/modes/select.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/js/id/modes/select.js b/js/id/modes/select.js index 1b42bf4a5..791ae7ec8 100644 --- a/js/id/modes/select.js +++ b/js/id/modes/select.js @@ -19,13 +19,14 @@ iD.modes.Select = function (entity) { mode.history.perform(iD.actions.Noop()); } - entity.nodes.forEach(function(n) { - var node = mode.history.graph().entity(n.id), + _.uniq(_.pluck(entity.nodes, 'id')) + .forEach(function(id) { + var node = mode.history.graph().entity(id), start = mode.map.projection(node.loc), end = mode.map.projection.invert([ - start[0] + d3.event.dx, - start[1] + d3.event.dy]); - mode.history.replace(iD.actions.Move(node.id, end)); + start[0] + d3.event.dx, + start[1] + d3.event.dy]); + mode.history.replace(iD.actions.Move(id, end)); }); }) .on('dragend', function () { From 554c4c82129174e2dd1dfb36d907d5b51010d5eb Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Wed, 12 Dec 2012 18:45:51 -0500 Subject: [PATCH 3/4] Fix bad tile on load. Fixes #192 --- js/id/renderer/background.js | 2 +- js/id/renderer/map.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/id/renderer/background.js b/js/id/renderer/background.js index 35fb4ea29..24da773d6 100644 --- a/js/id/renderer/background.js +++ b/js/id/renderer/background.js @@ -32,7 +32,7 @@ iD.Background = function() { function background() { var tiles = tile .scale(projection.scale()) - .scaleExtent(source.scaleExtent || [0, 17]) + .scaleExtent(source.scaleExtent || [1, 17]) .translate(projection.translate())(), scaleExtent = tile.scaleExtent(), z = Math.max(Math.log(projection.scale()) / Math.log(2) - 8, 0), diff --git a/js/id/renderer/map.js b/js/id/renderer/map.js index bfbd1efab..a0dbd4103 100644 --- a/js/id/renderer/map.js +++ b/js/id/renderer/map.js @@ -5,7 +5,7 @@ iD.Map = function() { selection = null, hover = null, translateStart, keybinding, - projection = d3.geo.mercator(), + projection = d3.geo.mercator().scale(1024), zoom = d3.behavior.zoom() .translate(projection.translate()) .scale(projection.scale()) From f0184fe8870af40643b6845da232257ba0f6ab51 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Wed, 12 Dec 2012 19:06:23 -0500 Subject: [PATCH 4/4] Fixup double click after, Fixes #254 --- js/id/renderer/map.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/id/renderer/map.js b/js/id/renderer/map.js index a0dbd4103..a79044b34 100644 --- a/js/id/renderer/map.js +++ b/js/id/renderer/map.js @@ -283,7 +283,11 @@ iD.Map = function() { function zoomPan() { if (d3.event && d3.event.sourceEvent.type === 'dblclick') { - if (!dblclickEnabled) return; + if (!dblclickEnabled) { + zoom.scale(projection.scale()) + .translate(projection.translate()); + return d3.event.sourceEvent.preventDefault(); + } } var fast = (d3.event.scale === projection.scale() && fastEnabled); projection