ALKMaps.Control.FeatureEvent

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

Inherits from

Example

var featureControl = new ALKMaps.Control.FeatureEvent([vectorLayer]);
map.addControls([featureControl, new ALKMaps.Control.MousePosition()]);
featureControl.handlers.feature.moveLayerToTop = function() {};
featureControl.handlers.feature.moveLayerBack = function() {};
featureControl.activate();
// additional code

var hoverHandler = function (event) {
    console.log("Mouse over feature.", event.feature);
    return false; // turn off default internal event handler.
};
vectorLayer.events.register('overFeature', this, hoverHandler);


var outHandler = function (event) {
    console.log("Mouse out feature.", event.feature);
    return false;
};
vectorLayer.events.register('outFeature', this, outHandler);


// Display the more detailed popup when a feature is clicked.
var clickHandler = function(event) {
    console.log("Mouse click on feature.", event.feature,
    " shiftKey: ", this.handlers.feature.evt.shiftKey,
    " ctrlKey: ", this.handlers.feature.evt.ctrlKey,
    " altKey: ", this.handlers.feature.evt.altKey);
    return false;
};
vectorLayer.events.register('featureclicked', featureControl, clickHandler);


var featurerightclicked = function(event) {
     console.log("Mouse R click on feature.", event.feature,
     " shiftKey: ", this.handlers.feature.evt.shiftKey,
     " ctrlKey: ", this.handlers.feature.evt.ctrlKey,
     " altKey: ", this.handlers.feature.evt.altKey);
     // map.disableContextMenu();
     // map.enableContextMenu();
     return false;
};
vectorLayer.events.register('featurerightclicked', featureControl, featurerightclicked);
Summary
ALKMaps.Control.FeatureEventThe FeatureEvent control selects vector features from a given layer on click or hover.
Properties
events{ALKMaps.Events} Events instance for listeners and triggering layer specific events.
handleRightClicks{Boolean} Whether or not to handle right clicks.
featureAttributesFilter{Object} To restrict matching feature by comparing feature attributes.
documentDrag{Boolean} If set to true, mouse dragging will continue even if the mouse cursor leaves the map viewport.
dragCallbacks{Object} The functions that are sent to the drag handler for callback.
Constructor
ALKMaps.Control.FeatureEventCreate a new control for selecting features.
Functions
deactivateDeactivate the control and all handlers.
clickFeatureUsed to trigger ‘featureclicked’ event.
rightClickFeatureUsed to trigger ‘featurerightclicked’ event.
clickoutFeatureUsed to trigger ‘featureclickedout’ event
rightClickoutFeatureUsed to trigger ‘featurerightclickedout’ event
overFeatureUsed to trigger ‘overFeature’ event.
downFeatureCalled when the drag handler detects a mouse-down.
moveFeatureCalled when the drag handler detects a mouse-move.
upFeatureCalled when the drag handler detects a mouse-up.
doneDraggingCalled when the drag handler is done dragging.
outFeatureUsed to trigger ‘outFeature’ event.

Properties

events

{ALKMaps.Events} Events instance for listeners and triggering layer specific events.

Register a listener for a particular event with the following syntax

layer.events.register(type, obj, listener);

Supported event types (in addition to those from <ALKMaps.Control.events>)

featureclickedTriggered when a feature is clicked.
featurerightclickedTriggered when a feature is right clicked
featureclickedoutTriggered when a click outside a feature.  Last stored feature will be returned in the event.
overFeatureTriggered when mouse over a feature.
outFeatureTriggered when mouse out a feature.

handleRightClicks

{Boolean} Whether or not to handle right clicks.

featureAttributesFilter

{Object} To restrict matching feature by comparing feature attributes.  Expected format: [{property: ‘isMarker’, value: true}]

documentDrag

{Boolean} If set to true, mouse dragging will continue even if the mouse cursor leaves the map viewport.  Default is false.

dragCallbacks

{Object} The functions that are sent to the drag handler for callback.

Constructor

ALKMaps.Control.FeatureEvent

Create a new control for selecting features.

Parameters

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

Functions

deactivate

deactivate: function()

Deactivate the control and all handlers.

Returns

{Boolean} Successfully deactivated the control.

clickFeature

clickFeature: function(feature)

Used to trigger ‘featureclicked’ event.

rightClickFeature

rightClickFeature: function (feature)

Used to trigger ‘featurerightclicked’ event.

clickoutFeature

clickoutFeature: function(feature)

Used to trigger ‘featureclickedout’ event

rightClickoutFeature

rightClickoutFeature: function(feature)

Used to trigger ‘featurerightclickedout’ event

overFeature

overFeature: function(feature)

Used to trigger ‘overFeature’ event.

downFeature

downFeature: function(pixel)

Called when the drag handler detects a mouse-down.

Parameters

pixel{ALKMaps.Pixel} Location of the mouse event.

moveFeature

moveFeature: function(pixel)

Called when the drag handler detects a mouse-move.  Also calls the optional onDrag method.

Parameters

pixel{ALKMaps.Pixel} Location of the mouse event.

upFeature

upFeature: function(pixel)

Called when the drag handler detects a mouse-up.

Parameters

pixel{ALKMaps.Pixel} Location of the mouse event.

doneDragging

doneDragging: function(pixel)

Called when the drag handler is done dragging.

Parameters

pixel{ALKMaps.Pixel} The last event pixel location.  If this event came from a mouseout, this may not be in the map viewport.

outFeature

outFeature: function(feature)

Used to trigger ‘outFeature’ event.

deactivate: function()
Deactivate the control and all handlers.
clickFeature: function(feature)
Used to trigger ‘featureclicked’ event.
rightClickFeature: function (feature)
Used to trigger ‘featurerightclicked’ event.
clickoutFeature: function(feature)
Used to trigger ‘featureclickedout’ event
rightClickoutFeature: function(feature)
Used to trigger ‘featurerightclickedout’ event
overFeature: function(feature)
Used to trigger ‘overFeature’ event.
downFeature: function(pixel)
Called when the drag handler detects a mouse-down.
moveFeature: function(pixel)
Called when the drag handler detects a mouse-move.
upFeature: function(pixel)
Called when the drag handler detects a mouse-up.
doneDragging: function(pixel)
Called when the drag handler is done dragging.
outFeature: function(feature)
Used to trigger ‘outFeature’ event.
The SelectFeature control selects vector features from a given layer on click or hover.
Instances of ALKMaps.Layer.Vector are used to render vector data from a variety of sources.
This class represents a screen coordinate, in x and y coordinates
Close