Remove skippeFeatures collection
This commit is contained in:
@@ -184,16 +184,12 @@ ol.interaction.Select.prototype.setMap = function(map) {
|
|||||||
var currentMap = this.getMap();
|
var currentMap = this.getMap();
|
||||||
var selectedFeatures = this.featureOverlay_.getFeatures();
|
var selectedFeatures = this.featureOverlay_.getFeatures();
|
||||||
if (!goog.isNull(currentMap)) {
|
if (!goog.isNull(currentMap)) {
|
||||||
selectedFeatures.forEach(function(feature) {
|
selectedFeatures.forEach(currentMap.unskipFeature, currentMap);
|
||||||
currentMap.getSkippedFeatures().remove(feature);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
goog.base(this, 'setMap', map);
|
goog.base(this, 'setMap', map);
|
||||||
this.featureOverlay_.setMap(map);
|
this.featureOverlay_.setMap(map);
|
||||||
if (!goog.isNull(map)) {
|
if (!goog.isNull(map)) {
|
||||||
selectedFeatures.forEach(function(feature) {
|
selectedFeatures.forEach(map.skipFeature, map);
|
||||||
map.getSkippedFeatures().push(feature);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -223,7 +219,7 @@ ol.interaction.Select.prototype.addFeature_ = function(evt) {
|
|||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
goog.asserts.assertInstanceof(feature, ol.Feature);
|
goog.asserts.assertInstanceof(feature, ol.Feature);
|
||||||
if (!goog.isNull(map)) {
|
if (!goog.isNull(map)) {
|
||||||
map.getSkippedFeatures().push(feature);
|
map.skipFeature(feature);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -237,6 +233,6 @@ ol.interaction.Select.prototype.removeFeature_ = function(evt) {
|
|||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
goog.asserts.assertInstanceof(feature, ol.Feature);
|
goog.asserts.assertInstanceof(feature, ol.Feature);
|
||||||
if (!goog.isNull(map)) {
|
if (!goog.isNull(map)) {
|
||||||
map.getSkippedFeatures().remove(feature);
|
map.unskipFeature(feature);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+20
-46
@@ -362,18 +362,6 @@ ol.Map = function(options) {
|
|||||||
goog.bind(this.getTilePriority, this),
|
goog.bind(this.getTilePriority, this),
|
||||||
goog.bind(this.handleTileChange_, this));
|
goog.bind(this.handleTileChange_, this));
|
||||||
|
|
||||||
/**
|
|
||||||
* Features to skip at rendering time.
|
|
||||||
* @type {ol.Collection}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
this.skippedFeatures_ = new ol.Collection();
|
|
||||||
goog.events.listen(this.skippedFeatures_, ol.CollectionEventType.ADD,
|
|
||||||
this.handleSkippedFeaturesAdd_, false, this);
|
|
||||||
goog.events.listen(this.skippedFeatures_, ol.CollectionEventType.REMOVE,
|
|
||||||
this.handleSkippedFeaturesRemove_, false, this);
|
|
||||||
this.registerDisposable(this.skippedFeatures_);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uids of features to skip at rendering time.
|
* Uids of features to skip at rendering time.
|
||||||
* @type {Object.<string, boolean>}
|
* @type {Object.<string, boolean>}
|
||||||
@@ -821,16 +809,6 @@ ol.Map.prototype.getTilePriority =
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the collection of features to skip.
|
|
||||||
* @return {ol.Collection} Features collection.
|
|
||||||
* @todo stability experimental
|
|
||||||
*/
|
|
||||||
ol.Map.prototype.getSkippedFeatures = function() {
|
|
||||||
return this.skippedFeatures_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
||||||
* @param {string=} opt_type Type.
|
* @param {string=} opt_type Type.
|
||||||
@@ -930,30 +908,6 @@ ol.Map.prototype.handleSizeChanged_ = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @param {ol.CollectionEvent} event Collection "add" event.
|
|
||||||
*/
|
|
||||||
ol.Map.prototype.handleSkippedFeaturesAdd_ = function(event) {
|
|
||||||
var feature = /** @type {ol.Feature} */ (event.element);
|
|
||||||
var featureUid = goog.getUid(feature).toString();
|
|
||||||
this.skippedFeatureUids_[featureUid] = true;
|
|
||||||
this.render();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @param {ol.CollectionEvent} event Collection "remove" event.
|
|
||||||
*/
|
|
||||||
ol.Map.prototype.handleSkippedFeaturesRemove_ = function(event) {
|
|
||||||
var feature = /** @type {ol.Feature} */ (event.element);
|
|
||||||
var featureUid = goog.getUid(feature).toString();
|
|
||||||
delete this.skippedFeatureUids_[featureUid];
|
|
||||||
this.render();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
@@ -1348,6 +1302,16 @@ goog.exportProperty(
|
|||||||
ol.Map.prototype.setView);
|
ol.Map.prototype.setView);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.Feature} feature Feature.
|
||||||
|
*/
|
||||||
|
ol.Map.prototype.skipFeature = function(feature) {
|
||||||
|
var featureUid = goog.getUid(feature).toString();
|
||||||
|
this.skippedFeatureUids_[featureUid] = true;
|
||||||
|
this.render();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force a recalculation of the map viewport size. This should be called when
|
* Force a recalculation of the map viewport size. This should be called when
|
||||||
* third-party code changes the size of the map viewport.
|
* third-party code changes the size of the map viewport.
|
||||||
@@ -1371,6 +1335,16 @@ ol.Map.prototype.updateSize = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.Feature} feature Feature.
|
||||||
|
*/
|
||||||
|
ol.Map.prototype.unskipFeature = function(feature) {
|
||||||
|
var featureUid = goog.getUid(feature).toString();
|
||||||
|
delete this.skippedFeatureUids_[featureUid];
|
||||||
|
this.render();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{controls: ol.Collection,
|
* @typedef {{controls: ol.Collection,
|
||||||
* deviceOptions: olx.DeviceOptions,
|
* deviceOptions: olx.DeviceOptions,
|
||||||
|
|||||||
Reference in New Issue
Block a user