mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-07 03:41:33 +00:00
Fix way node dragging. Fixes #97
This commit is contained in:
@@ -8,6 +8,12 @@ iD.Util.id = function(counter) {
|
||||
return counter[0] + (--iD.Util._counters[counter]);
|
||||
};
|
||||
|
||||
iD.Util.trueObj = function(arr) {
|
||||
var o = {};
|
||||
for (var i = 0, l = arr.length; i < l; i++) o[arr[i]] = true;
|
||||
return o;
|
||||
};
|
||||
|
||||
iD.Util.friendlyName = function(entity) {
|
||||
// Generate a string such as 'river' or 'Fred's House' for an entity.
|
||||
if (!Object.keys(entity.tags).length) { return ''; }
|
||||
|
||||
@@ -31,6 +31,14 @@ iD.Graph.prototype = {
|
||||
return this.entities[id];
|
||||
},
|
||||
|
||||
parents: function(id) {
|
||||
// This is slow and a bad hack.
|
||||
return _.filter(this.entities, function(e) {
|
||||
if (e.type !== 'way') return false;
|
||||
return e.nodes.indexOf(id) !== -1;
|
||||
});
|
||||
},
|
||||
|
||||
merge: function(graph) {
|
||||
var entities = _.clone(this.entities);
|
||||
_.defaults(entities, graph.entities);
|
||||
|
||||
@@ -16,9 +16,12 @@ iD.Map = function(elem, connection) {
|
||||
.scale(projection.scale())
|
||||
.scaleExtent([256, 134217728])
|
||||
.on('zoom', zoomPan),
|
||||
only,
|
||||
dragbehavior = d3.behavior.drag()
|
||||
.origin(function(entity) {
|
||||
var p = projection(ll2a(entity));
|
||||
only = iD.Util.trueObj([entity.id].concat(
|
||||
_.pluck(history.graph().parents(entity.id), 'id')));
|
||||
return { x: p[0], y: p[1] };
|
||||
})
|
||||
.on('dragstart', function() {
|
||||
@@ -27,8 +30,6 @@ iD.Map = function(elem, connection) {
|
||||
.on('drag', function(entity) {
|
||||
var to = projection.invert([d3.event.x, d3.event.y]);
|
||||
history.replace(iD.actions.move(entity, to));
|
||||
var only = {};
|
||||
only[entity.id] = true;
|
||||
redraw(only);
|
||||
})
|
||||
.on('dragend', update),
|
||||
@@ -126,7 +127,7 @@ iD.Map = function(elem, connection) {
|
||||
if (!only) {
|
||||
all = graph.intersects(extent);
|
||||
} else {
|
||||
for (var id in only) all.push(graph.entity(id));
|
||||
for (var id in only) all.push(graph.fetch(id));
|
||||
}
|
||||
|
||||
var filter = only ?
|
||||
|
||||
@@ -26,7 +26,7 @@ iD.Inspector = function() {
|
||||
iD.format.GeoJSON.mapping(d), null, 2));
|
||||
});
|
||||
if (selection.datum().type === 'way') {
|
||||
head.append('a')
|
||||
selection.append('a')
|
||||
.attr('class', 'permalink')
|
||||
.attr('href', '#')
|
||||
.text('Reverse Direction')
|
||||
@@ -39,7 +39,6 @@ iD.Inspector = function() {
|
||||
}
|
||||
|
||||
function inspector(selection) {
|
||||
// http://jsfiddle.net/7WQjr/
|
||||
selection.each(function(entity) {
|
||||
selection.html("").append('button')
|
||||
.text('x').attr({ title: 'close', 'class': 'close' })
|
||||
|
||||
Reference in New Issue
Block a user