Defer selection/deselection

This commit is contained in:
Éric Lemoine
2014-06-26 10:03:23 +02:00
parent bcdce20ee3
commit 0762b8c023
2 changed files with 10 additions and 3 deletions

View File

@@ -150,6 +150,8 @@ ol.interaction.Select.prototype.handleMapBrowserEvent =
} }
} else { } else {
// Modify the currently selected feature(s). // Modify the currently selected feature(s).
var /** @type {Array.<number>} */ deselected = [];
var /** @type {Array.<ol.Feature>} */ selected = [];
map.forEachFeatureAtPixel(mapBrowserEvent.pixel, map.forEachFeatureAtPixel(mapBrowserEvent.pixel,
/** /**
* @param {ol.Feature} feature Feature. * @param {ol.Feature} feature Feature.
@@ -159,14 +161,19 @@ ol.interaction.Select.prototype.handleMapBrowserEvent =
var index = goog.array.indexOf(features.getArray(), feature); var index = goog.array.indexOf(features.getArray(), feature);
if (index == -1) { if (index == -1) {
if (add || toggle) { if (add || toggle) {
features.push(feature); selected.push(feature);
} }
} else { } else {
if (remove || toggle) { if (remove || toggle) {
features.removeAt(index); deselected.push(index);
} }
} }
}, undefined, this.layerFilter_); }, undefined, this.layerFilter_);
var i;
for (i = deselected.length - 1; i >= 0; --i) {
features.removeAt(deselected[i]);
}
features.extend(selected);
} }
return false; return false;
}; };

View File

@@ -1202,7 +1202,7 @@ ol.Map.prototype.renderFrame_ = function(time) {
pixelToCoordinateMatrix: this.pixelToCoordinateMatrix_, pixelToCoordinateMatrix: this.pixelToCoordinateMatrix_,
postRenderFunctions: [], postRenderFunctions: [],
size: size, size: size,
skippedFeatureUids_: goog.object.clone(this.skippedFeatureUids_), skippedFeatureUids_: this.skippedFeatureUids_,
tileQueue: this.tileQueue_, tileQueue: this.tileQueue_,
time: time, time: time,
usedTiles: {}, usedTiles: {},