# OpenLayers.Control.SelectFeature

The SelectFeature control selects vector features from a given layer on click or hover.

#### Inherits from

- OpenLayers.Control

Summary

OpenLayers.Control.SelectFeature | The SelectFeature control selects vector features from a given layer on click or hover.
Constants |
EVENT_TYPES |
Properties |
multipleKey | {String} An event modifier (‘altKey’ or ‘shiftKey’) that temporarily sets the multiple property to true.
toggleKey | {String} An event modifier (‘altKey’ or ‘shiftKey’) that temporarily sets the toggle property to true.
multiple | {Boolean} Allow selection of multiple geometries.
clickout | {Boolean} Unselect features when clicking outside any feature.
toggle | {Boolean} Unselect a selected feature on click.
hover | {Boolean} Select on mouse over and deselect on mouse out.
highlightOnly | {Boolean} If true do not actually select features (that is place them in the layer’s selected features array), just highlight them.
box | {Boolean} Allow feature selection by drawing a box.
onBeforeSelect | {Function} Optional function to be called before a feature is selected.
onSelect | {Function} Optional function to be called when a feature is selected.
onUnselect | {Function} Optional function to be called when a feature is unselected.
scope | {Object} The scope to use with the onBeforeSelect, onSelect, onUnselect callbacks.
geometryTypes | {Array(String)} To restrict selecting to a limited set of geometry types, send a list of strings corresponding to the geometry class names.
layer | {OpenLayers.Layer.Vector} The vector layer with a common renderer root for all layers this control is configured with (if an array of layers was passed to the constructor), or the vector layer the control was configured with (if a single layer was passed to the constructor).
layers | {Array(OpenLayers.Layer.Vector)} The layers this control will work on, or null if the control was configured with a single layer
callbacks | {Object} The functions that are sent to the handlers.feature for callback
selectStyle | {Object} Hash of styles
renderIntent | {String} key used to retrieve the select style from the layer’s style map.
handlers | {Object} Object with references to multiple OpenLayers.Handler instances.
Constructor |
OpenLayers.Control.SelectFeature | Create a new control for selecting features.
Functions |
initLayer | Assign the layer property.
destroy |
activate | Activates the control.
deactivate | Deactivates the control.
unselectAll | Unselect all selected features.
clickFeature | Called on click in a feature Only responds if this.hover is false.
multipleSelect | Allow for multiple selected features based on multiple property and multipleKey event modifier.
toggleSelect | Event should toggle the selected state of a feature based on toggle property and toggleKey event modifier.
clickoutFeature | Called on click outside a previously clicked (selected) feature.
overFeature | Called on over a feature.
outFeature | Called on out of a selected feature.
highlight | Redraw feature with the select style.
unhighlight | Redraw feature with the “default” style
select | Add feature to the layer’s selectedFeature array, render the feature as selected, and call the onSelect function.
unselect | Remove feature from the layer’s selectedFeature array, render the feature as normal, and call the onUnselect function.
selectBox | Callback from the handlers.box set up when box selection is true on.
setMap | Set the map property for the control.
setLayer | Attach a new layer to the control, overriding any existing layers.

### Constants

### EVENT_TYPES

#### Supported event types

- beforefeaturehighlighted Triggered before a feature is highlighted
- featurehighlighted Triggered when a feature is highlighted
- featureunhighlighted Triggered when a feature is unhighlighted

### Properties

### multipleKey

{String} An event modifier (‘altKey’ or ‘shiftKey’) that temporarily sets the multiple property to true. Default is null.

### toggleKey

{String} An event modifier (‘altKey’ or ‘shiftKey’) that temporarily sets the toggle property to true. Default is null.

### multiple

{Boolean} Allow selection of multiple geometries. Default is false.

### clickout

{Boolean} Unselect features when clicking outside any feature. Default is true.

### toggle

{Boolean} Unselect a selected feature on click. Default is false. Only has meaning if hover is false.

### hover

{Boolean} Select on mouse over and deselect on mouse out. If true, this ignores clicks and only listens to mouse moves.

### highlightOnly

{Boolean} If true do not actually select features (that is place them in the layer’s selected features array), just highlight them. This property has no effect if hover is false. Defaults to false.

### box

{Boolean} Allow feature selection by drawing a box.

### onBeforeSelect

{Function} Optional function to be called before a feature is selected. The function should expect to be called with a feature.

### onSelect

{Function} Optional function to be called when a feature is selected. The function should expect to be called with a feature.

### onUnselect

{Function} Optional function to be called when a feature is unselected. The function should expect to be called with a feature.

### scope

{Object} The scope to use with the onBeforeSelect, onSelect, onUnselect callbacks. If null the scope will be this control.

### geometryTypes

{Array(String)} To restrict selecting to a limited set of geometry types, send a list of strings corresponding to the geometry class names.

### layer

{OpenLayers.Layer.Vector} The vector layer with a common renderer root for all layers this control is configured with (if an array of layers was passed to the constructor), or the vector layer the control was configured with (if a single layer was passed to the constructor).

### layers

{Array(OpenLayers.Layer.Vector)} The layers this control will work on, or null if the control was configured with a single layer

### callbacks

{Object} The functions that are sent to the handlers.feature for callback

### selectStyle

{Object} Hash of styles

### renderIntent

{String} key used to retrieve the select style from the layer’s style map.

### handlers

{Object} Object with references to multiple OpenLayers.Handler instances.

### Constructor

### OpenLayers.Control.SelectFeature

Create a new control for selecting features.

#### Parameters

layers | {OpenLayers.Layer.Vector}, or an array of vector layers. The layer(s) this control will select features from.
options | {Object}

### Functions

### initLayer

> initLayer: function( | layers | )

Assign the layer property. If layers is an array, we need to use a RootContainer.

#### Parameters

layers | {OpenLayers.Layer.Vector}, or an array of vector layers.

### destroy

> destroy: function()

### activate

> activate: function ()

Activates the control.

#### Returns

{Boolean} The control was effectively activated.

### deactivate

> deactivate: function ()

Deactivates the control.

#### Returns

{Boolean} The control was effectively deactivated.

### unselectAll

> unselectAll: function( | options | )

Unselect all selected features. To unselect all except for a single feature, set the options.except property to the feature.

#### Parameters

options | {Object} Optional configuration object.

### clickFeature

> clickFeature: function( | feature | )

Called on click in a feature Only responds if this.hover is false.

#### Parameters

feature | {OpenLayers.Feature.Vector}

### multipleSelect

> multipleSelect: function()

Allow for multiple selected features based on multiple property and multipleKey event modifier.

#### Returns

{Boolean} Allow for multiple selected features.

### toggleSelect

> toggleSelect: function()

Event should toggle the selected state of a feature based on toggle property and toggleKey event modifier.

#### Returns

{Boolean} Toggle the selected state of a feature.

### clickoutFeature

> clickoutFeature: function( | feature | )

Called on click outside a previously clicked (selected) feature. Only responds if this.hover is false.

#### Parameters

feature | {<OpenLayers.Vector.Feature>}

### overFeature

> overFeature: function( | feature | )

Called on over a feature. Only responds if this.hover is true.

#### Parameters

feature | {OpenLayers.Feature.Vector}

### outFeature

> outFeature: function( | feature | )

Called on out of a selected feature. Only responds if this.hover is true.

#### Parameters

feature | {OpenLayers.Feature.Vector}

### highlight

> highlight: function( | feature | )

Redraw feature with the select style.

#### Parameters

feature | {OpenLayers.Feature.Vector}

### unhighlight

> unhighlight: function( | feature | )

Redraw feature with the “default” style

#### Parameters

feature | {OpenLayers.Feature.Vector}

### select

> select: function( | feature | )

Add feature to the layer’s selectedFeature array, render the feature as selected, and call the onSelect function.

#### Parameters

feature | {OpenLayers.Feature.Vector}

### unselect

> unselect: function( | feature | )

Remove feature from the layer’s selectedFeature array, render the feature as normal, and call the onUnselect function.

#### Parameters

feature | {OpenLayers.Feature.Vector}

### selectBox

> selectBox: function( | position | )

Callback from the handlers.box set up when box selection is true on.

#### Parameters

position | {OpenLayers.Bounds || OpenLayers.Pixel }

### setMap

> setMap: function( | map | )

Set the map property for the control.

#### Parameters

map | {OpenLayers.Map}

### setLayer

> setLayer: function( | layers | )

Attach a new layer to the control, overriding any existing layers.

#### Parameters

layers | Array of {OpenLayers.Layer.Vector} or a single {OpenLayers.Layer.Vector}

{Boolean} Allow selection of multiple geometries.
{Boolean} Unselect a selected feature on click.
Instances of OpenLayers.Layer.Vector are used to render vector data from a variety of sources.
Base class to construct a higher-level handler for event sequences.

> initLayer: function( | layers | )

Assign the layer property.

> destroy: function()

> activate: function ()

Activates the control.

> deactivate: function ()

Deactivates the control.

> unselectAll: function( | options | )

Unselect all selected features.

> clickFeature: function( | feature | )

Called on click in a feature Only responds if this.hover is false.

> multipleSelect: function()

Allow for multiple selected features based on multiple property and multipleKey event modifier.
{String} An event modifier (‘altKey’ or ‘shiftKey’) that temporarily sets the multiple property to true.

> toggleSelect: function()

Event should toggle the selected state of a feature based on toggle property and toggleKey event modifier.
{String} An event modifier (‘altKey’ or ‘shiftKey’) that temporarily sets the toggle property to true.

> clickoutFeature: function( | feature | )

Called on click outside a previously clicked (selected) feature.

> overFeature: function( | feature | )

Called on over a feature.

> outFeature: function( | feature | )

Called on out of a selected feature.

> highlight: function( | feature | )

Redraw feature with the select style.

> unhighlight: function( | feature | )

Redraw feature with the “default” style

> select: function( | feature | )

Add feature to the layer’s selectedFeature array, render the feature as selected, and call the onSelect function.

> unselect: function( | feature | )

Remove feature from the layer’s selectedFeature array, render the feature as normal, and call the onUnselect function.

> selectBox: function( | position | )

Callback from the handlers.box set up when box selection is true on.
{Boolean} Allow feature selection by drawing a box.

> setMap: function( | map | )

Set the map property for the control.

> setLayer: function( | layers | )

Attach a new layer to the control, overriding any existing layers.
Controls affect the display or behavior of the map.
Vector features use the OpenLayers.Geometry classes as geometry description.
Instances of this class represent bounding boxes.
This class represents a screen coordinate, in x and y coordinates
Instances of OpenLayers.Map are interactive maps embedded in a web page.
Close