Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make handling of skipped features faster #1997

Merged
merged 1 commit into from
Apr 18, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 21 additions & 13 deletions src/ol/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,10 @@ ol.Map = function(options) {
* @private
*/
this.skippedFeatures_ = new ol.Collection();
goog.events.listen(this.skippedFeatures_,
[ol.CollectionEventType.ADD, ol.CollectionEventType.REMOVE],
this.handleSkippedFeaturesChange_, false, this);
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_);

/**
Expand Down Expand Up @@ -931,17 +932,24 @@ ol.Map.prototype.handleSizeChanged_ = function() {

/**
* @private
* @param {ol.CollectionEvent} event Collection "add" event.
*/
ol.Map.prototype.handleSkippedFeaturesChange_ = function() {
this.skippedFeatureUids_ = {};
this.skippedFeatures_.forEach(
/**
* @param {ol.Feature} feature Feature.
* @this {ol.Map}
*/
function(feature) {
this.skippedFeatureUids_[goog.getUid(feature).toString()] = true;
}, this);
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();
};

Expand Down