Merge pull request #1065 from ahocevar/skip-hidden

Select interaction does not work with shape symbolizers and canvas renderer
This commit is contained in:
ahocevar
2013-09-27 05:45:50 -07:00
3 changed files with 19 additions and 3 deletions

View File

@@ -311,9 +311,14 @@
/** /**
* @typedef {Object} ol.interaction.SelectOptions * @typedef {Object} ol.interaction.SelectOptions
* @property {ol.interaction.ConditionType|undefined} addCondition A conditional
* modifier (e.g. shift key) that determines if the selection is added to
* the current selection. By default, a shift-click adds to the current
* selection.
* @property {ol.interaction.ConditionType|undefined} condition A conditional * @property {ol.interaction.ConditionType|undefined} condition A conditional
* modifier (i.e. Shift key) that determines if the interaction is active * modifier (e.g. shift key) that determines if the interaction is active
* or not, default is on mouse click only. * (i.e. selection occurs) or not. By default, a click with no modifier keys
* toggles the selection.
* @property {undefined|function(ol.layer.Layer):boolean} layerFilter Filter * @property {undefined|function(ol.layer.Layer):boolean} layerFilter Filter
* function to restrict selection to a subset of layers. * function to restrict selection to a subset of layers.
*/ */

View File

@@ -28,6 +28,13 @@ ol.interaction.Select = function(opt_options) {
this.condition_ = goog.isDef(options.condition) ? this.condition_ = goog.isDef(options.condition) ?
options.condition : ol.interaction.condition.clickOnly; options.condition : ol.interaction.condition.clickOnly;
/**
* @private
* @type {ol.interaction.ConditionType}
*/
this.addCondition_ = goog.isDef(options.addCondition) ?
options.addCondition : ol.interaction.condition.shiftKeyOnly;
/** /**
* Mapping between original features and cloned features on selection layers. * Mapping between original features and cloned features on selection layers.
* @type {Object.<*,Object.<*,ol.Feature>>} * @type {Object.<*,Object.<*,ol.Feature>>}
@@ -65,7 +72,7 @@ ol.interaction.Select.prototype.handleMapBrowserEvent =
if (!goog.isNull(this.layerFilter_)) { if (!goog.isNull(this.layerFilter_)) {
layers = goog.array.filter(layers, this.layerFilter_); layers = goog.array.filter(layers, this.layerFilter_);
} }
var clear = !ol.interaction.condition.shiftKeyOnly(mapBrowserEvent); var clear = !this.addCondition_(mapBrowserEvent);
var that = this; var that = this;
var select = function(featuresByLayer) { var select = function(featuresByLayer) {

View File

@@ -14,6 +14,7 @@ goog.require('ol.extent');
goog.require('ol.geom.GeometryType'); goog.require('ol.geom.GeometryType');
goog.require('ol.layer.Vector'); goog.require('ol.layer.Vector');
goog.require('ol.layer.VectorLayerEventType'); goog.require('ol.layer.VectorLayerEventType');
goog.require('ol.layer.VectorLayerRenderIntent');
goog.require('ol.renderer.canvas.Layer'); goog.require('ol.renderer.canvas.Layer');
goog.require('ol.renderer.canvas.VectorRenderer'); goog.require('ol.renderer.canvas.VectorRenderer');
goog.require('ol.tilegrid.TileGrid'); goog.require('ol.tilegrid.TileGrid');
@@ -271,6 +272,9 @@ ol.renderer.canvas.VectorLayer.prototype.getFeaturesForPixel =
halfWidth, halfHeight, uid, coordinates, j; halfWidth, halfHeight, uid, coordinates, j;
for (var id in candidates) { for (var id in candidates) {
candidate = candidates[id]; candidate = candidates[id];
if (candidate.renderIntent == ol.layer.VectorLayerRenderIntent.HIDDEN) {
continue;
}
geom = candidate.getGeometry(); geom = candidate.getGeometry();
type = geom.getType(); type = geom.getType();
if (type === ol.geom.GeometryType.POINT || if (type === ol.geom.GeometryType.POINT ||