Make sure that #clear() keeps the collection in sync
This commit is contained in:
@@ -372,26 +372,30 @@ ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) {
|
||||
*/
|
||||
ol.source.Vector.prototype.clear = function(opt_fast) {
|
||||
if (opt_fast) {
|
||||
for (var featureId in this.featureChangeKeys_) {
|
||||
var keys = this.featureChangeKeys_[featureId];
|
||||
goog.array.forEach(keys, goog.events.unlistenByKey);
|
||||
if (goog.isNull(this.featuresCollection_)) {
|
||||
for (var featureId in this.featureChangeKeys_) {
|
||||
var keys = this.featureChangeKeys_[featureId];
|
||||
goog.array.forEach(keys, goog.events.unlistenByKey);
|
||||
}
|
||||
this.featureChangeKeys_ = {};
|
||||
this.idIndex_ = {};
|
||||
this.undefIdIndex_ = {};
|
||||
} else {
|
||||
this.featuresCollection_.clear();
|
||||
}
|
||||
this.featureChangeKeys_ = {};
|
||||
this.idIndex_ = {};
|
||||
this.undefIdIndex_ = {};
|
||||
} else {
|
||||
var rmFeatureInternal = this.removeFeatureInternal;
|
||||
if (!goog.isNull(this.featuresRtree_)) {
|
||||
this.featuresRtree_.forEach(rmFeatureInternal, this);
|
||||
goog.object.forEach(this.nullGeometryFeatures_, rmFeatureInternal, this);
|
||||
}
|
||||
goog.asserts.assert(goog.object.isEmpty(this.featureChangeKeys_),
|
||||
'featureChangeKeys is an empty object now');
|
||||
goog.asserts.assert(goog.object.isEmpty(this.idIndex_),
|
||||
'idIndex is an empty object now');
|
||||
goog.asserts.assert(goog.object.isEmpty(this.undefIdIndex_),
|
||||
'undefIdIndex is an empty object now');
|
||||
}
|
||||
goog.asserts.assert(goog.object.isEmpty(this.featureChangeKeys_),
|
||||
'featureChangeKeys is an empty object now');
|
||||
goog.asserts.assert(goog.object.isEmpty(this.idIndex_),
|
||||
'idIndex is an empty object now');
|
||||
goog.asserts.assert(goog.object.isEmpty(this.undefIdIndex_),
|
||||
'undefIdIndex is an empty object now');
|
||||
|
||||
if (!goog.isNull(this.featuresRtree_)) {
|
||||
this.featuresRtree_.clear();
|
||||
|
||||
Reference in New Issue
Block a user