Class: Select

ol.interaction.Select

Handles selection of vector data. A ol.FeatureOverlay is maintained internally to store the selected feature(s). Which features are selected is determined by the condition option, and optionally the toggle or add/remove options.

new ol.interaction.Select(opt_options)

Name Type Description
options

Options.

Name Type Description
addCondition ol.events.ConditionType | undefined experimental

A function that takes an ol.MapBrowserEvent and returns a boolean to indicate whether that event should be handled. By default, this is ol.events.condition.never. Use this if you want to use different events for add and remove instead of toggle.

condition ol.events.ConditionType | undefined experimental

A function that takes an ol.MapBrowserEvent and returns a boolean to indicate whether that event should be handled. This is the event for the selected features as a whole. By default, this is ol.events.condition.singleClick. Clicking on a feature selects that feature and removes any that were in the selection. Clicking outside any feature removes all from the selection. See toggle, add, remove options for adding/removing extra features to/ from the selection.

layers Array.<ol.layer.Layer> | function experimental

A list of layers from which features should be selected. Alternatively, a filter function can be provided. The function will be called for each layer in the map and should return true for layers that you want to be selectable. If the option is absent, all visible layers will be considered selectable.

style ol.style.Style | Array.<ol.style.Style> | ol.style.StyleFunction | undefined experimental

Style for the selected features (those in the FeatureOverlay).

removeCondition ol.events.ConditionType | undefined experimental

A function that takes an ol.MapBrowserEvent and returns a boolean to indicate whether that event should be handled. By default, this is ol.events.condition.never. Use this if you want to use different events for add and remove instead of toggle.

toggleCondition ol.events.ConditionType | undefined experimental

A function that takes an ol.MapBrowserEvent and returns a boolean to indicate whether that event should be handled. This is in addition to the condition event. By default, ol.events.condition.shiftKeyOnly, i.e. pressing shift as well as the condition event, adds that feature to the current selection if it is not currently selected, and removes it if it is. See add and remove if you want to use different events instead of a toggle.

Extends

Methods

dispatchChangeEvent() inherited experimental

Dispatches a change event.

Fires:
  • change experimental

Get the selected features.

Returns:
Features collection.

getRevision(){number} inherited experimental

Returns:
Revision.

on(type, listener, opt_this){goog.events.Key} inherited

Listen for a certain type of event.

Name Type Description
type string | Array.<string>

The event type or array of event types.

listener function

The listener function.

this Object

The object to use as this in listener.

Returns:
Unique key for the listener.

once(type, listener, opt_this){goog.events.Key} inherited

Listen once for a certain type of event.

Name Type Description
type string | Array.<string>

The event type or array of event types.

listener function

The listener function.

this Object

The object to use as this in listener.

Returns:
Unique key for the listener.

Remove the interaction from its current map, if any, and attach it to a new map, if any. Pass null to just remove the interaction from the current map.

Name Type Description
map ol.Map

Map.

un(type, listener, opt_this) inherited

Unlisten for a certain type of event.

Name Type Description
type string | Array.<string>

The event type or array of event types.

listener function

The listener function.

this Object

The object which was used as this by the listener.

Removes an event listener using the key returned by on() or once().

Name Type Description
key goog.events.Key

Key.