mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Cache bounds and be smarter about reassigning marker properties
This commit is contained in:
@@ -32,6 +32,7 @@ iD.Way.prototype = {
|
||||
addNode: function(node) {
|
||||
node.entity.addParent(this);
|
||||
this.nodes.push(node);
|
||||
this._bounds = null;
|
||||
return this;
|
||||
},
|
||||
|
||||
@@ -63,9 +64,14 @@ iD.Way.prototype = {
|
||||
};
|
||||
},
|
||||
|
||||
updateBounds: function() {
|
||||
this._bounds = d3.geo.bounds(this.toGeoJSON());
|
||||
},
|
||||
|
||||
bounds: function() {
|
||||
// TODO: cache
|
||||
return d3.geo.bounds(this.toGeoJSON());
|
||||
if (!this._bounds) this.updateBounds();
|
||||
return this._bounds;
|
||||
},
|
||||
|
||||
// ---------------------
|
||||
|
||||
@@ -261,10 +261,12 @@ iD.Map = function(obj) {
|
||||
.attr('class', classes('stroke'));
|
||||
|
||||
markers.enter().append('image')
|
||||
.on('click', selectClick);
|
||||
markers.attr('class', classes('marker'))
|
||||
.attr('class', classes('marker'))
|
||||
.on('click', selectClick)
|
||||
.attr({ width: 16, height: 16 })
|
||||
.attr('xlink:href', markerimage)
|
||||
.attr('xlink:href', markerimage);
|
||||
|
||||
markers
|
||||
.attr('transform', function(d) {
|
||||
return 'translate(' + projection(d) + ')';
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user