mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Points always need full re-render (#569)
This commit is contained in:
@@ -147,6 +147,7 @@ window.iD = function () {
|
||||
context.surface = function() { return map.surface; };
|
||||
context.mouse = map.mouse;
|
||||
context.projection = map.projection;
|
||||
context.extent = map.extent;
|
||||
context.redraw = map.redraw;
|
||||
context.pan = map.pan;
|
||||
context.zoomIn = map.zoomIn;
|
||||
|
||||
@@ -139,7 +139,7 @@ iD.Map = function(context) {
|
||||
}
|
||||
|
||||
surface
|
||||
.call(points, graph, all, filter)
|
||||
.call(points)
|
||||
.call(vertices, graph, all, filter, map.extent(), map.zoom())
|
||||
.call(lines, graph, all, filter)
|
||||
.call(areas, graph, all, filter)
|
||||
|
||||
@@ -10,15 +10,8 @@ iD.svg.Points = function(projection, context) {
|
||||
return b.loc[1] - a.loc[1];
|
||||
}
|
||||
|
||||
return function drawPoints(surface, graph, entities, filter) {
|
||||
var points = [];
|
||||
|
||||
for (var i = 0; i < entities.length; i++) {
|
||||
var entity = entities[i];
|
||||
if (entity.geometry(graph) === 'point') {
|
||||
points.push(entity);
|
||||
}
|
||||
}
|
||||
function drawPoints(surface, points) {
|
||||
points = points || drawPoints.points();
|
||||
|
||||
if (points.length > 100) {
|
||||
return surface.select('.layer-hit').selectAll('g.point').remove();
|
||||
@@ -27,7 +20,6 @@ iD.svg.Points = function(projection, context) {
|
||||
points.sort(sortY);
|
||||
|
||||
var groups = surface.select('.layer-hit').selectAll('g.point')
|
||||
.filter(filter)
|
||||
.data(points, iD.Entity.key);
|
||||
|
||||
var group = groups.enter()
|
||||
@@ -55,11 +47,28 @@ iD.svg.Points = function(projection, context) {
|
||||
groups.select('.stroke');
|
||||
groups.select('.icon')
|
||||
.attr('xlink:href', function(entity) {
|
||||
var preset = context.presets().match(entity, graph);
|
||||
var preset = context.presets().match(entity, context.graph());
|
||||
return preset.icon ? '#maki-' + preset.icon + '-12' : '';
|
||||
});
|
||||
|
||||
groups.exit()
|
||||
.remove();
|
||||
}
|
||||
|
||||
drawPoints.points = function() {
|
||||
var graph = context.graph(),
|
||||
entities = context.intersects(context.extent()),
|
||||
points = [];
|
||||
|
||||
for (var i = 0; i < entities.length; i++) {
|
||||
var entity = entities[i];
|
||||
if (entity.geometry(graph) === 'point') {
|
||||
points.push(entity);
|
||||
}
|
||||
}
|
||||
|
||||
return points;
|
||||
};
|
||||
|
||||
return drawPoints;
|
||||
};
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
describe("iD.svg.Points", function () {
|
||||
var surface,
|
||||
projection = Object,
|
||||
filter = d3.functor(true),
|
||||
context;
|
||||
|
||||
beforeEach(function () {
|
||||
context = iD();
|
||||
surface = d3.select(document.createElementNS('http://www.w3.org/2000/svg', 'svg'))
|
||||
.call(iD.svg.Surface(iD()));
|
||||
.call(iD.svg.Surface(context));
|
||||
});
|
||||
|
||||
it("adds tag classes", function () {
|
||||
var node = iD.Node({tags: {amenity: "cafe"}, loc: [0, 0], _poi: true}),
|
||||
graph = iD.Graph([node]);
|
||||
var point = iD.Node({tags: {amenity: "cafe"}, loc: [0, 0]});
|
||||
|
||||
surface.call(iD.svg.Points(projection, context), graph, [node], filter);
|
||||
surface.call(iD.svg.Points(projection, context), [point]);
|
||||
|
||||
expect(surface.select('.point')).to.be.classed('tag-amenity');
|
||||
expect(surface.select('.point')).to.be.classed('tag-amenity-cafe');
|
||||
|
||||
Reference in New Issue
Block a user