OpenLayers.Control.GetFeature - OpenLayers

# OpenLayers.Control.GetFeature

Gets vector features for locations underneath the mouse cursor. Can be configured to act on click, hover or dragged boxes. Uses an OpenLayers.Protocol that supports spatial filters to retrieve features from a server and fires events that notify applications of the selected features.

#### Inherits from

- OpenLayers.Control

Summary

OpenLayers.Control.GetFeature | Gets vector features for locations underneath the mouse cursor.
Properties |
protocol | {OpenLayers.Protocol} Required.
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.
modifiers | {Object} The event modifiers to use, according to the current event being handled by this control’s handlers
multiple | {Boolean} Allow selection of multiple geometries.
click | {Boolean} Use a click handler for selecting/unselecting features.
single | {Boolean} Tells whether select by click should select a single feature.
clickout | {Boolean} Unselect features when clicking outside any feature.
toggle | {Boolean} Unselect a selected feature on click.
clickTolerance | {Integer} Tolerance for the filter query in pixels.
hover | {Boolean} Send feature requests on mouse moves.
box | {Boolean} Allow feature selection by drawing a box.
maxFeatures | {Integer} Maximum number of features to return from a query in single mode if supported by the protocol.
features | {Object} Hash of {OpenLayers.Feature.Vector}, keyed by fid, holding the currently selected features
handlerOptions | {Object} Additional options for the handlers used by this control.
handlers | {Object} Object with references to multiple OpenLayers.Handler instances.
hoverResponse | {OpenLayers.Protocol.Response} The response object associated with the currently running hover request (if any).
filterType | {String} The type of filter to use when sending off a request.
events | {OpenLayers.Events} Events instance for listeners and triggering control specific events.
Constructor |
OpenLayers.Control.GetFeature | Create a new control for fetching remote features.
Functions |
activate | Activates the control.
deactivate | Deactivates the control.
selectClick | Called on click
selectBox | Callback from the handlers.box set up when box selection is on
selectHover | Callback from the handlers.hover set up when hover selection is on
cancelHover | Callback from the handlers.hover set up when hover selection is on
request | Sends a GetFeature request to the WFS
selectBestFeature | Selects the feature from an array of features that is the best match for the click position.
setModifiers | Sets the multiple and toggle modifiers according to the current event
select | Add feature to the hash of selected features and trigger the featureselected and featuresselected events.
hoverSelect | Sets/unsets the <hoverFeature>
unselect | Remove feature from the hash of selected features and trigger the featureunselected event.
unselectAll | Unselect all selected features.
setMap | Set the map property for the control.
pixelToBounds | Takes a pixel as argument and creates bounds after adding the clickTolerance.

### Properties

### protocol

{OpenLayers.Protocol} Required. The protocol used for fetching features.

### 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.

### modifiers

{Object} The event modifiers to use, according to the current event being handled by this control’s handlers

### multiple

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

### click

{Boolean} Use a click handler for selecting/unselecting features. If both click and box are set to true, the click handler takes precedence over the box handler if a box with zero extent was selected. Default is true.

### single

{Boolean} Tells whether select by click should select a single feature. If set to false, all matching features are selected. If set to true, only the best matching feature is selected. This option has an effect only of the click option is set to true. Default is true.

### clickout

{Boolean} Unselect features when clicking outside any feature. Applies only if click is true. Default is true.

### toggle

{Boolean} Unselect a selected feature on click. Applies only if click is true. Default is false.

### clickTolerance

{Integer} Tolerance for the filter query in pixels. This has the same effect as the tolerance parameter on WMS GetFeatureInfo requests. Will be ignored for box selections. Applies only if click or hover is true. Default is 5. Note that this not only affects requests on click, but also on hover.

### hover

{Boolean} Send feature requests on mouse moves. Default is false.

### box

{Boolean} Allow feature selection by drawing a box. If set to true set click to false to disable the click handler and rely on the box handler only, even for “zero extent” boxes. See the description of the click option for additional information. Default is false.

### maxFeatures

{Integer} Maximum number of features to return from a query in single mode if supported by the protocol. This set of features is then used to determine the best match client-side. Default is 10.

### features

{Object} Hash of {OpenLayers.Feature.Vector}, keyed by fid, holding the currently selected features

### handlerOptions

{Object} Additional options for the handlers used by this control. This is a hash with the keys “click”, “box” and “hover”.

### handlers

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

### hoverResponse

{OpenLayers.Protocol.Response} The response object associated with the currently running hover request (if any).

### filterType

{String} The type of filter to use when sending off a request. Possible values: OpenLayers.Filter.Spatial.<BBOX|INTERSECTS|WITHIN|CONTAINS> Defaults to: OpenLayers.Filter.Spatial.BBOX

### events

{OpenLayers.Events} Events instance for listeners and triggering control specific events.

#### Register a listener for a particular event with the following syntax

>     control.events.register(type, obj, listener);

#### Supported event types (in addition to those from OpenLayers.Control.events)

beforefeatureselected | Triggered when click is true before a feature is selected. The event object has a feature property with the feature about to select
featureselected | Triggered when click is true and a feature is selected. The event object has a feature property with the selected feature
beforefeaturesselected | Triggered when click is true before a set of features is selected. The event object is an array of feature properties with the features about to be selected. Return false after receiving this event to discontinue processing of all featureselected events and the featuresselected event.
featuresselected | Triggered when click is true and a set of features is selected. The event object is an array of feature properties of the selected features
featureunselected | Triggered when click is true and a feature is unselected. The event object has a feature property with the unselected feature
clickout | Triggered when when click is true and no feature was selected.
hoverfeature | Triggered when hover is true and the mouse has stopped over a feature
outfeature | Triggered when hover is true and the mouse moves moved away from a hover-selected feature

### Constructor

### OpenLayers.Control.GetFeature

Create a new control for fetching remote features.

#### Parameters

options | {Object} A configuration object which at least has to contain a protocol property (if not, it has to be set before a request is made)

### Functions

### 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.

### selectClick

> selectClick: function( | evt | )

Called on click

#### Parameters

evt | {OpenLayers.Event}

### selectBox

> selectBox: function( | position | )

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

#### Parameters

position | {<OpenLayers.Bounds>|Object} An OpenLayers.Bounds or an object with a ‘left’, ‘bottom’, ‘right’ and ‘top’ properties.

### selectHover

> selectHover: function( | evt | )

Callback from the handlers.hover set up when hover selection is on

#### Parameters

evt | {Object} event object with an xy property

### cancelHover

> cancelHover: function()

Callback from the handlers.hover set up when hover selection is on

### request

> request: function( | bounds,
> | options | )

Sends a GetFeature request to the WFS

#### Parameters

bounds | {OpenLayers.Bounds} bounds for the request’s BBOX filter
options | {Object} additional options for this method.

#### Supported options include

single | {Boolean} A single feature should be returned. Note that this will be ignored if the protocol does not return the geometries of the features.
hover | {Boolean} Do the request for the hover handler.

### selectBestFeature

> selectBestFeature: function( | features,
> | clickPosition,
> | options | )

Selects the feature from an array of features that is the best match for the click position.

#### Parameters

features | {Array(OpenLayers.Feature.Vector)}
clickPosition | {OpenLayers.LonLat}
options | {Object} additional options for this method

#### Supported options include

hover | {Boolean} Do the selection for the hover handler.

### setModifiers

> setModifiers: function( | evt | )

Sets the multiple and toggle modifiers according to the current event

#### Parameters

evt | {OpenLayers.Event}

### select

> select: function( | features | )

Add feature to the hash of selected features and trigger the featureselected and featuresselected events.

#### Parameters

features | {OpenLayers.Feature.Vector} or an array of features

### hoverSelect

> hoverSelect: function( | feature | )

Sets/unsets the <hoverFeature>

#### Parameters

feature | {OpenLayers.Feature.Vector} the feature to hover-select. If none is provided, the current <hoverFeature> will be nulled and the outfeature event will be triggered.

### unselect

> unselect: function( | feature | )

Remove feature from the hash of selected features and trigger the featureunselected event.

#### Parameters

feature | {OpenLayers.Feature.Vector}

### unselectAll

> unselectAll: function()

Unselect all selected features.

### setMap

> setMap: function( | map | )

Set the map property for the control.

#### Parameters

map | {OpenLayers.Map}

### pixelToBounds

> pixelToBounds: function( | pixel | )

Takes a pixel as argument and creates bounds after adding the clickTolerance.

#### Parameters

pixel | {OpenLayers.Pixel}

Abstract vector layer protocol class.
{Boolean} Allow selection of multiple geometries.
{Boolean} Unselect a selected feature on click.
{OpenLayers.Protocol} Required.
Vector features use the OpenLayers.Geometry classes as geometry description.
Base class to construct a higher-level handler for event sequences.
Protocols return Response objects to their users.
Contains convenience functions for string manipulation.

> activate: function ()

Activates the control.

> deactivate: function ()

Deactivates the control.

> selectClick: function( | evt | )

Called on click

> selectBox: function( | position | )

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

> selectHover: function( | evt | )

Callback from the handlers.hover set up when hover selection is on
{Boolean} Send feature requests on mouse moves.

> cancelHover: function()

Callback from the handlers.hover set up when hover selection is on

> request: function( | bounds,
> | options | )

Sends a GetFeature request to the WFS

> selectBestFeature: function( | features,
> | clickPosition,
> | options | )

Selects the feature from an array of features that is the best match for the click position.

> setModifiers: function( | evt | )

Sets the multiple and toggle modifiers according to the current event

> select: function( | features | )

Add feature to the hash of selected features and trigger the featureselected and featuresselected events.

> hoverSelect: function( | feature | )

Sets/unsets the hoverFeature

> unselect: function( | feature | )

Remove feature from the hash of selected features and trigger the featureunselected event.

> unselectAll: function()

Unselect all selected features.

> setMap: function( | map | )

Set the map property for the control.

> pixelToBounds: function( | pixel | )

Takes a pixel as argument and creates bounds after adding the clickTolerance.
{Integer} Tolerance for the filter query in pixels.
Controls affect the display or behavior of the map.
{Boolean} Use a click handler for selecting/unselecting features.
{OpenLayers.Events} Events instance for listeners and triggering control specific events.
Utility functions for event handling.
Instances of this class represent bounding boxes.
This class represents a longitude and latitude pair
Instances of OpenLayers.Map are interactive maps embedded in a web page.
This class represents a screen coordinate, in x and y coordinates
Close