Merge pull request #2012 from elemoine/skipfeature
Remove skippeFeatures collection
This commit is contained in:
@@ -184,16 +184,12 @@ ol.interaction.Select.prototype.setMap = function(map) {
|
||||
var currentMap = this.getMap();
|
||||
var selectedFeatures = this.featureOverlay_.getFeatures();
|
||||
if (!goog.isNull(currentMap)) {
|
||||
selectedFeatures.forEach(function(feature) {
|
||||
currentMap.getSkippedFeatures().remove(feature);
|
||||
});
|
||||
selectedFeatures.forEach(currentMap.unskipFeature, currentMap);
|
||||
}
|
||||
goog.base(this, 'setMap', map);
|
||||
this.featureOverlay_.setMap(map);
|
||||
if (!goog.isNull(map)) {
|
||||
selectedFeatures.forEach(function(feature) {
|
||||
map.getSkippedFeatures().push(feature);
|
||||
});
|
||||
selectedFeatures.forEach(map.skipFeature, map);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -223,7 +219,7 @@ ol.interaction.Select.prototype.addFeature_ = function(evt) {
|
||||
var map = this.getMap();
|
||||
goog.asserts.assertInstanceof(feature, ol.Feature);
|
||||
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();
|
||||
goog.asserts.assertInstanceof(feature, ol.Feature);
|
||||
if (!goog.isNull(map)) {
|
||||
map.getSkippedFeatures().remove(feature);
|
||||
map.unskipFeature(feature);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -362,18 +362,6 @@ ol.Map = function(options) {
|
||||
goog.bind(this.getTilePriority, 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.
|
||||
* @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 {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
|
||||
*/
|
||||
@@ -1348,6 +1302,16 @@ goog.exportProperty(
|
||||
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
|
||||
* 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,
|
||||
* deviceOptions: olx.DeviceOptions,
|
||||
|
||||
Reference in New Issue
Block a user