OpenLayers.Handler.Feature

Handler to respond to mouse events related to a drawn feature.  Callbacks with the following keys will be notified of the following events associated with features: click, clickout, over, out, and dblclick.

This handler stops event propagation for mousedown and mouseup if those browser events target features that can be selected.

Inherits from

Summary
OpenLayers.Handler.FeatureHandler to respond to mouse events related to a drawn feature.
Properties
EVENTMAP{Object} A object mapping the browser events to objects with callback keys for in and out.
feature{OpenLayers.Feature.Vector} The last feature that was hovered.
lastFeature{OpenLayers.Feature.Vector} The last feature that was handled.
down{OpenLayers.Pixel} The location of the last mousedown.
up{OpenLayers.Pixel} The location of the last mouseup.
clickTolerance{Number} The number of pixels the mouse can move between mousedown and mouseup for the event to still be considered a click.
geometryTypesTo restrict dragging to a limited set of geometry types, send a list of strings corresponding to the geometry class names.
stopClick{Boolean} If stopClick is set to true, handled clicks do not propagate to other click listeners.
stopDown{Boolean} If stopDown is set to true, handled mousedowns do not propagate to other mousedown listeners.
stopUp{Boolean} If stopUp is set to true, handled mouseups do not propagate to other mouseup listeners.
Constructor
OpenLayers.Handler.Feature
Functions
touchstartHandle touchstart events
touchmoveHandle touchmove events.
mousedownHandle mouse down.
mouseupHandle mouse up.
clickHandle click.
mousemoveHandle mouse moves.
dblclickHandle dblclick.
geometryTypeMatchesReturn true if the geometry type of the passed feature matches one of the geometry types in the geometryTypes array.
handle
triggerCallbackCall the callback keyed in the event map with the supplied arguments.
activateTurn on the handler.
deactivateTurn off the handler.
handleMapEvents
moveLayerToTopMoves the layer for this handler to the top, so mouse events can reach it.
moveLayerBackMoves the layer back to the position determined by the map’s layers array.

Properties

EVENTMAP

{Object} A object mapping the browser events to objects with callback keys for in and out.

feature

{OpenLayers.Feature.Vector} The last feature that was hovered.

lastFeature

{OpenLayers.Feature.Vector} The last feature that was handled.

down

{OpenLayers.Pixel} The location of the last mousedown.

up

{OpenLayers.Pixel} The location of the last mouseup.

clickTolerance

{Number} The number of pixels the mouse can move between mousedown and mouseup for the event to still be considered a click.  Dragging the map should not trigger the click and clickout callbacks unless the map is moved by less than this tolerance.  Defaults to 4.

geometryTypes

To restrict dragging to a limited set of geometry types, send a list of strings corresponding to the geometry class names.

@type Array(String)

stopClick

{Boolean} If stopClick is set to true, handled clicks do not propagate to other click listeners.  Otherwise, handled clicks do propagate.  Unhandled clicks always propagate, whatever the value of stopClick.  Defaults to true.

stopDown

{Boolean} If stopDown is set to true, handled mousedowns do not propagate to other mousedown listeners.  Otherwise, handled mousedowns do propagate.  Unhandled mousedowns always propagate, whatever the value of stopDown.  Defaults to true.

stopUp

{Boolean} If stopUp is set to true, handled mouseups do not propagate to other mouseup listeners.  Otherwise, handled mouseups do propagate.  Unhandled mouseups always propagate, whatever the value of stopUp.  Defaults to false.

Constructor

OpenLayers.Handler.Feature

Parameters

control{OpenLayers.Control}
layer{OpenLayers.Layer.Vector}
callbacks{Object} An object with a ‘over’ property whos value is a function to be called when the mouse is over a feature.  The callback should expect to recieve a single argument, the feature.
options{Object}

Functions

touchstart

touchstart: function(evt)

Handle touchstart events

Parameters

evt{Event}

Returns

{Boolean} Let the event propagate.

touchmove

touchmove: function(evt)

Handle touchmove events.  We just prevent the browser default behavior, for Android Webkit not to select text when moving the finger after selecting a feature.

Parameters

evt{Event}

mousedown

mousedown: function(evt)

Handle mouse down.  Stop propagation if a feature is targeted by this event (stops map dragging during feature selection).

Parameters

evt{Event}

mouseup

mouseup: function(evt)

Handle mouse up.  Stop propagation if a feature is targeted by this event.

Parameters

evt{Event}

click

click: function(evt)

Handle click.  Call the “click” callback if click on a feature, or the “clickout” callback if click outside any feature.

Parameters

evt{Event}

Returns

{Boolean}

mousemove

mousemove: function(evt)

Handle mouse moves.  Call the “over” callback if moving in to a feature, or the “out” callback if moving out of a feature.

Parameters

evt{Event}

Returns

{Boolean}

dblclick

dblclick: function(evt)

Handle dblclick.  Call the “dblclick” callback if dblclick on a feature.

Parameters

evt{Event}

Returns

{Boolean}

geometryTypeMatches

geometryTypeMatches: function(feature)

Return true if the geometry type of the passed feature matches one of the geometry types in the geometryTypes array.

Parameters

feature{<OpenLayers.Vector.Feature>}

Returns

{Boolean}

handle

handle: function(evt)

Parameters

evt{Event}

Returns

{Boolean} The event occurred over a relevant feature.

triggerCallback

triggerCallback: function(type,
mode,
args)

Call the callback keyed in the event map with the supplied arguments.  For click and clickout, the clickTolerance is checked first.

Parameters

type{String}

activate

activate: function()

Turn on the handler.  Returns false if the handler was already active.

Returns

{Boolean}

deactivate

deactivate: function()

Turn off the handler.  Returns false if the handler was already active.

Returns

{Boolean}

handleMapEvents

handleMapEvents: function(evt)

Parameters

evt{Object}

moveLayerToTop

moveLayerToTop: function()

Moves the layer for this handler to the top, so mouse events can reach it.

moveLayerBack

moveLayerBack: function()

Moves the layer back to the position determined by the map’s layers array.

Vector features use the OpenLayers.Geometry classes as geometry description.
This class represents a screen coordinate, in x and y coordinates
touchstart: function(evt)
Handle touchstart events
touchmove: function(evt)
Handle touchmove events.
mousedown: function(evt)
Handle mouse down.
mouseup: function(evt)
Handle mouse up.
click: function(evt)
Handle click.
mousemove: function(evt)
Handle mouse moves.
dblclick: function(evt)
Handle dblclick.
geometryTypeMatches: function(feature)
Return true if the geometry type of the passed feature matches one of the geometry types in the geometryTypes array.
handle: function(evt)
triggerCallback: function(type,
mode,
args)
Call the callback keyed in the event map with the supplied arguments.
activate: function()
Turn on the handler.
deactivate: function()
Turn off the handler.
handleMapEvents: function(evt)
moveLayerToTop: function()
Moves the layer for this handler to the top, so mouse events can reach it.
moveLayerBack: function()
Moves the layer back to the position determined by the map’s layers array.
Base class to construct a higher-level handler for event sequences.
Controls affect the display or behavior of the map.
Instances of OpenLayers.Layer.Vector are used to render vector data from a variety of sources.
{Number} The number of pixels the mouse can move between mousedown and mouseup for the event to still be considered a click.
Close