The FeatureEvent control selects vector features from a given layer on click or hover.
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);| ALKMaps. | The 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. | Create a new control for selecting features. |
| Functions | |
| deactivate | Deactivate the control and all handlers. |
| clickFeature | Used to trigger ‘featureclicked’ event. |
| rightClickFeature | Used to trigger ‘featurerightclicked’ event. |
| clickoutFeature | Used to trigger ‘featureclickedout’ event |
| rightClickoutFeature | Used to trigger ‘featurerightclickedout’ event |
| overFeature | Used to trigger ‘overFeature’ event. |
| downFeature | Called when the drag handler detects a mouse-down. |
| moveFeature | Called when the drag handler detects a mouse-move. |
| upFeature | Called when the drag handler detects a mouse-up. |
| doneDragging | Called when the drag handler is done dragging. |
| outFeature | Used to trigger ‘outFeature’ event. |
{ALKMaps.Events} Events instance for listeners and triggering layer specific events.
layer.events.register(type, obj, listener);
| featureclicked | Triggered when a feature is clicked. |
| featurerightclicked | Triggered when a feature is right clicked |
| featureclickedout | Triggered when a click outside a feature. Last stored feature will be returned in the event. |
| overFeature | Triggered when mouse over a feature. |
| outFeature | Triggered when mouse out a feature. |
Create a new control for selecting features.
| layers | {ALKMaps.Layer.Vector}, or an array of vector layers. The layer(s) this control will select features from. |
| options | {Object} |
downFeature: function( pixel )
Called when the drag handler detects a mouse-down.
| pixel | {ALKMaps.Pixel} Location of the mouse event. |
moveFeature: function( pixel )
Called when the drag handler detects a mouse-move. Also calls the optional onDrag method.
| pixel | {ALKMaps.Pixel} Location of the mouse event. |
upFeature: function( pixel )
Called when the drag handler detects a mouse-up.
| pixel | {ALKMaps.Pixel} Location of the mouse event. |
doneDragging: function( pixel )
Called when the drag handler is done dragging.
| pixel | {ALKMaps.Pixel} The last event pixel location. If this event came from a mouseout, this may not be in the map viewport. |
Deactivate the control and all handlers.
deactivate: function()
Used to trigger ‘featureclicked’ event.
clickFeature: function( feature )
Used to trigger ‘featurerightclicked’ event.
rightClickFeature: function ( feature )
Used to trigger ‘featureclickedout’ event
clickoutFeature: function( feature )
Used to trigger ‘featurerightclickedout’ event
rightClickoutFeature: function( feature )
Used to trigger ‘overFeature’ event.
overFeature: function( feature )
Called when the drag handler detects a mouse-down.
downFeature: function( pixel )
Called when the drag handler detects a mouse-move.
moveFeature: function( pixel )
Called when the drag handler detects a mouse-up.
upFeature: function( pixel )
Called when the drag handler is done dragging.
doneDragging: function( pixel )
Used to trigger ‘outFeature’ event.
outFeature: function( feature )