From f40e12ba1db0969cf70cf8dd649378cae1c08ca7 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Tue, 13 Nov 2012 21:45:04 -0500 Subject: [PATCH] Fix dragging nodes that are members of multiple ways --- css/map.css | 5 +++++ js/iD/actions/actions.js | 10 ++++++++-- js/iD/renderer/Map.js | 14 +++++++------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/css/map.css b/css/map.css index 2323d6902..42c08eb94 100644 --- a/css/map.css +++ b/css/map.css @@ -40,6 +40,11 @@ circle.teaser-point { stroke-width: 3; } +.casing:hover { + stroke:#FF0F0F !important; + opacity:0.8; +} + .casing.active { stroke:#FFF9C9; stroke-opacity:1; diff --git a/js/iD/actions/actions.js b/js/iD/actions/actions.js index 89baf9363..604bdad3d 100644 --- a/js/iD/actions/actions.js +++ b/js/iD/actions/actions.js @@ -150,10 +150,16 @@ iD.actions.DrawRoad = function(way) { this._doubleTime = window.setTimeout(function(e) { return function() { d3.event = e; + var t = d3.select(d3.event.target); d3.event.stopPropagation(); + // connect a way to an existing way + if (t.data() && t.data()[0] && t.data()[0].type === 'node') { + node = t.data()[0]; + } else { + node = iD.actions._node(that.map.projection.invert( + d3.mouse(surface.node()))); + } way.nodes.pop(); - var ll = that.map.projection.invert(d3.mouse(surface.node())); - var node = iD.actions._node(ll); way.nodes.push(node.id); that.map.operate(iD.operations.changeWayNodes(way, node)); way.nodes = way.nodes.slice(); diff --git a/js/iD/renderer/Map.js b/js/iD/renderer/Map.js index dd03368c3..70912de18 100755 --- a/js/iD/renderer/Map.js +++ b/js/iD/renderer/Map.js @@ -108,7 +108,10 @@ iD.Map = function(elem) { var graph = history.graph(), all = graph.intersects(getExtent()); - var ways = [], areas = [], points = []; + var ways = [], + areas = [], + points = [], + waynodes = []; var active_entity = null; var selected_id = selection; @@ -125,6 +128,8 @@ iD.Map = function(elem) { } } else if (a._poi) { points.push(a); + } else if (!a._poi && a.type === 'node') { + waynodes.push(a); } } @@ -183,12 +188,7 @@ iD.Map = function(elem) { }); var handles = hit_g.selectAll('rect.handle') - // TODO: this could be faster - .data(areas.reduce(function(memo, w) { - return memo.concat(w.nodes); - }, ways.reduce(function(memo, w) { - return memo.concat(w.nodes); - }, [])), key); + .data(waynodes, key); handles.exit().remove(); handles.enter().append('rect')