mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-14 21:28:11 +02:00
Always-on handles, start intersecting elements again, fetch elements
early
This commit is contained in:
+4
-4
@@ -20,11 +20,11 @@ g.marker.active circle {
|
||||
}
|
||||
|
||||
/* interactive elements */
|
||||
circle.handle {
|
||||
rect.handle {
|
||||
cursor: move;
|
||||
stroke-width: 2;
|
||||
fill:#000;
|
||||
stroke:#FFF694;
|
||||
stroke-width: 1;
|
||||
stroke:#000;
|
||||
fill:#FFF694;
|
||||
}
|
||||
|
||||
circle.teaser-point {
|
||||
|
||||
@@ -69,9 +69,7 @@
|
||||
});
|
||||
|
||||
var m = d3.select('#map');
|
||||
|
||||
iD.Hash().map(map);
|
||||
|
||||
var controller = iD.Controller(map);
|
||||
|
||||
d3.selectAll('button#place').on('click', function() {
|
||||
|
||||
+18
-1
@@ -30,8 +30,25 @@ iD.Graph.prototype = {
|
||||
// get all objects that intersect an extent.
|
||||
intersects: function(extent) {
|
||||
var items = [];
|
||||
function nodeIntersect(entity) {
|
||||
return entity.lon > extent[0][0] &&
|
||||
entity.lon < extent[1][0] &&
|
||||
entity.lat < extent[0][1] &&
|
||||
entity.lat > extent[1][1];
|
||||
}
|
||||
for (var i in this.entities) {
|
||||
if (this.entities[i]) items.push(this.entities[i]);
|
||||
var entity = this.entities[i];
|
||||
if (entity.type === 'node' && nodeIntersect(entity)) {
|
||||
items.push(entity);
|
||||
} else if (entity.type === 'way') {
|
||||
var w = this.fetch(entity.id);
|
||||
for (var j = 0; j < w.nodes.length; j++) {
|
||||
if (nodeIntersect(w.nodes[j])) {
|
||||
items.push(w);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return items;
|
||||
},
|
||||
|
||||
+1
-1
@@ -9,6 +9,6 @@
|
||||
|
||||
iD.Way = {
|
||||
isClosed: function(w) {
|
||||
return (!w.nodes.length) || w.nodes[w.nodes.length - 1] === w.nodes[0];
|
||||
return (!w.nodes.length) || w.nodes[w.nodes.length - 1].id === w.nodes[0].id;
|
||||
}
|
||||
};
|
||||
|
||||
+15
-11
@@ -56,14 +56,11 @@ iD.Map = function(elem) {
|
||||
}),
|
||||
// geo
|
||||
linegen = d3.svg.line()
|
||||
.defined(function(d) {
|
||||
return !!history.entity(d);
|
||||
})
|
||||
.x(function(d) {
|
||||
return projection(ll2a(history.entity(d)))[0];
|
||||
return projection(ll2a(d))[0];
|
||||
})
|
||||
.y(function(d) {
|
||||
return projection(ll2a(history.entity(d)))[1];
|
||||
return projection(ll2a(d))[1];
|
||||
}),
|
||||
// Abstract linegen so that it pulls from `.children`. This
|
||||
// makes it possible to call simply `.attr('d', nodeline)`.
|
||||
@@ -189,16 +186,23 @@ iD.Map = function(elem) {
|
||||
return 'translate(' + pt + ')';
|
||||
});
|
||||
|
||||
var handles = hit_g.selectAll('circle.handle')
|
||||
.data(active_entity ? graph.fetch(active_entity.id).nodes : []);
|
||||
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);
|
||||
|
||||
handles.exit().remove();
|
||||
handles.enter().append('circle')
|
||||
.attr('class', 'handle')
|
||||
.attr('r', 3)
|
||||
handles.enter().append('rect')
|
||||
.attr({width: 4, height: 4, 'class': 'handle'})
|
||||
.call(dragbehavior);
|
||||
handles.attr('transform', function(entity) {
|
||||
return 'translate(' + projection(ll2a(entity)) + ')';
|
||||
var p = projection(ll2a(entity));
|
||||
p[0] -= 2;
|
||||
p[1] -= 2;
|
||||
return 'translate(' + p + ') rotate(45, 2, 2)';
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user