Create the R-Tree in the Modify constructor

In this way features can be added/removed to/from the R-Tree even when the interaction does not have a map.
This commit is contained in:
Éric Lemoine
2014-03-28 16:07:03 +01:00
parent c33a3372d9
commit afa5f35cef

View File

@@ -80,7 +80,7 @@ ol.interaction.Modify = function(options) {
* @type {Object.<*, ol.structs.RBush>}
* @private
*/
this.rBush_ = null;
this.rBush_ = new ol.structs.RBush();
/**
* @type {number}
@@ -140,15 +140,6 @@ goog.inherits(ol.interaction.Modify, ol.interaction.Pointer);
* @inheritDoc
*/
ol.interaction.Modify.prototype.setMap = function(map) {
if (!goog.isNull(map)) {
if (goog.isNull(this.rBush_)) {
this.rBush_ = new ol.structs.RBush();
}
} else {
// removing from a map, clean up
this.rBush_ = null;
}
this.overlay_.setMap(map);
goog.base(this, 'setMap', map);
};