Don't draw offscreen vertices (fixes #1494)

This commit is contained in:
John Firebaugh
2013-05-16 15:28:24 -07:00
parent fdc5824c5a
commit 1cfeba3da4
2 changed files with 11 additions and 11 deletions
+4 -4
View File
@@ -62,7 +62,7 @@ iD.Map = function(context) {
surface.on('mouseover.vertices', function() {
if (map.editable() && !transformed) {
var hover = d3.event.target.__data__;
surface.call(vertices.drawHover, context.graph(), hover, map.zoom());
surface.call(vertices.drawHover, context.graph(), hover, map.extent(), map.zoom());
dispatch.drawn(map);
}
});
@@ -70,7 +70,7 @@ iD.Map = function(context) {
surface.on('mouseout.vertices', function() {
if (map.editable() && !transformed) {
var hover = d3.event.relatedTarget && d3.event.relatedTarget.__data__;
surface.call(vertices.drawHover, context.graph(), hover, map.zoom());
surface.call(vertices.drawHover, context.graph(), hover, map.extent(), map.zoom());
dispatch.drawn(map);
}
});
@@ -81,7 +81,7 @@ iD.Map = function(context) {
filter = d3.functor(true),
extent = map.extent(),
graph = context.graph();
surface.call(vertices, graph, all, filter, map.zoom());
surface.call(vertices, graph, all, filter, extent, map.zoom());
surface.call(midpoints, graph, all, filter, extent);
dispatch.drawn(map);
}
@@ -138,7 +138,7 @@ iD.Map = function(context) {
} else {
surface
.call(points, graph, all, filter)
.call(vertices, graph, all, filter, map.zoom())
.call(vertices, graph, all, filter, extent, map.zoom())
.call(lines, graph, all, filter)
.call(areas, graph, all, filter)
.call(midpoints, graph, all, filter, extent)
+7 -7
View File
@@ -8,14 +8,14 @@ iD.svg.Vertices = function(projection, context) {
var hover;
function siblingAndChildVertices(ids, graph) {
function siblingAndChildVertices(ids, graph, extent) {
var vertices = {};
function addChildVertices(entity) {
var i;
if (entity.type === 'way') {
for (i = 0; i < entity.nodes.length; i++) {
vertices[entity.nodes[i]] = graph.entity(entity.nodes[i]);
addChildVertices(graph.entity(entity.nodes[i]));
}
} else if (entity.type === 'relation') {
for (i = 0; i < entity.members.length; i++) {
@@ -24,7 +24,7 @@ iD.svg.Vertices = function(projection, context) {
addChildVertices(member);
}
}
} else {
} else if (entity.intersects(extent, graph)) {
vertices[entity.id] = entity;
}
}
@@ -107,8 +107,8 @@ iD.svg.Vertices = function(projection, context) {
.remove();
}
function drawVertices(surface, graph, entities, filter, zoom) {
var selected = siblingAndChildVertices(context.selection(), graph),
function drawVertices(surface, graph, entities, filter, extent, zoom) {
var selected = siblingAndChildVertices(context.selection(), graph, extent),
vertices = [];
for (var i = 0; i < entities.length; i++) {
@@ -131,8 +131,8 @@ iD.svg.Vertices = function(projection, context) {
drawHover(surface, graph, zoom);
}
function drawHover(surface, graph, zoom) {
var hovered = hover ? siblingAndChildVertices([hover.id], graph) : {};
function drawHover(surface, graph, extent, zoom) {
var hovered = hover ? siblingAndChildVertices([hover.id], graph, extent) : {};
surface.select('.layer-hit').selectAll('g.vertex.vertex-hover')
.call(draw, d3.values(hovered), 'vertex-hover', graph, zoom);