Handle feature's geometries changing to and from null in ol.source.Vector

This commit is contained in:
Tom Payne
2013-12-20 14:42:50 +01:00
parent 4b9451de81
commit 8a7ae264e1
2 changed files with 64 additions and 1 deletions

View File

@@ -279,7 +279,22 @@ ol.source.Vector.prototype.getExtent = function() {
*/
ol.source.Vector.prototype.handleFeatureChange_ = function(event) {
var feature = /** @type {ol.Feature} */ (event.target);
this.rBush_.update(feature.getGeometry().getExtent(), feature);
var featureKey = goog.getUid(feature).toString();
var geometry = feature.getGeometry();
if (goog.isNull(geometry)) {
if (!(featureKey in this.nullGeometryFeatures_)) {
this.rBush_.remove(feature);
this.nullGeometryFeatures_[featureKey] = feature;
}
} else {
var extent = geometry.getExtent();
if (featureKey in this.nullGeometryFeatures_) {
delete this.nullGeometryFeatures_[featureKey];
this.rBush_.insert(extent, feature);
} else {
this.rBush_.update(extent, feature);
}
}
this.dispatchChangeEvent();
};