/mapview/interactions/highlight
The module exports the highlight interaction method which is bound to a mapview in the decorator method.
Requires
Methods
(inner) clear()
The clear method will clear the current feature and shortcircuit if there is no current feature.
The infotip object [eg. hover] will be removed.
The cursor will be reset.
The layer.L change event will be called to trigger the featureStyle render.
(inner) click(e)
The click() method is assigned to the mapview.Map element click event listener. The method will reset the cursor and check for execution of the interaction.longClickMethod.
The method is debounced to 600ms with interaction.clicked flag.
The pointerMove method will be called with the click event [location] to get a feature without a cursor.
The interaction.Click method will be called if it exists. This will shortcircuit the getFeature method.
The interaction.noLocationClick method will be called if no current location is available.
Otherwise the interaction.current feature is passed to the interaction.getFeature method.
Name | Type | Description |
---|---|---|
e | Object | The calling event. |
(inner) finish()
The [highlight] interaction will be cleared.
Any popup will be removed from mapview.
Event listener will be removed the mapview.Map element.
(inner) getFeature(feature)
The getFeature method deals with cluster features.
A dialog to select a cluster feature will be presented.
The interaction.getFeature method can be overwritten in the params passed to the highlight interaction.
The nnearest method is called for cluster features which are not created from a vector source.
Name | Type | Description |
---|---|---|
feature | Object | The feature to get. |
(inner) highlight(params)
The highlight interaction method is bound to a mapview object [this].
The highlight interaction method will call the finish() method of the mapview.interaction before assigning a highlight interaction object as mapview.interaction.
The configuration params are spread into the interaction configuration overriding any of the defaults.
The highlight interaction works by assigning mousedown, touchstart, mouseup, and mouseleave events to the mapview.Map object.
The optional getLocation function property will be executed the mapp.location.get() method.
Name | Type | Description |
---|---|---|
params | object | The params object is spread into the interaction defaults. |
Name | Type | Attributes | Description |
---|---|---|---|
getLocation | function | <optional> | Will be executed after the getFeature method. |
(inner) layerFilter(L)
The layerFilter method filters mapview layers with a qID.
Name | Type | Description |
---|---|---|
L | Object | Openlayers layer. |
(inner) mouseDown()
The mouseDown event method enables the longClickMethod.
The cursor is set to wait after the longClickTimeout event.
The longClickTimeout is cleared in the pointerMove and click event methods.
(inner) mouseUp()
The mouseUp event method reset the cursor to auto.
(inner) mouseleave()
The mouseleave event method will be triggered when the cursor leaves the mapview.Map element.
The method will empty the interaction.candidateKeys set and call the clear method.
(inner) pointerMove(e)
The pointerMove event method will clear the interaction.longClickTimeout number before assigning each feature intersecting with the event [pixel] location.
Each feature is stored in the candidates object in the forEachFeatureAtPixel callback method.
The interaction.layerFilter method is assigned as an option to filter feature from relevant feature layer.
A candidate object consists of a key, the Openlayers layer object L, and the feature object F itself.
The method checks whether a Set candidates objects keys is different from the interaction.candidateKeys set to determine whether the highlight feature has changed.
The interaction.candidateKeys set will be cleared and the clear method is called if there are no candidate features.
The method will shortcircuit if the are no candidates or the highlight stays the same.
Otherwise a feature is chosen which is not in the interaction.candidateKeys set.
The method will shortcircuit if the chosen feature key is the same as the interaction.current [feature] key.
Otherwise the clear method is called and the feature is assigned as the interaction.current thereafter.
The pointerMove method will be called from a touch click event in order to select features on a touch screen. However there is no cursor and the highlight style should not be applied nor should the hover method be called. The pointerMove method will shortcircuit if called with a touch event.
Otherwise the cursor will check to a pointer if selection is possible.
The feature will be passed as argument to a feature.layer.hover method.
Finally the layer.L change event will be called to trigger the featureStyle render.
Name | Type | Description |
---|---|---|
e | Object | The pointerMove event. |
Name | Type | Description |
---|---|---|
e.pixel | Object | The pixel object for the current pointer location. |
(inner) touchStart()
The touchStart event prevents the mouseDown event on touch input.
Type Definitions
interaction
The highlight interaction object.
- Object
Name | Type | Description |
---|---|---|
getFeature | function | Method to return a feature from the highlight or click event methods. |
longClickMethod | function | Defaults to mapview.allFeatures() |
longClickTimeout | Number | Timeout for the execution of the longClickMethod. |
longClickMS | Integer | Milliseconds for longClickTimeout. Defaults to 500ms. |
longClick | Boolean | Execute longClick method. |
hitTolerance | Number | Pixel distance for detection of features on pixel. Defaults to 5pixel. |
candidateKeys | Set | A set of candidate features under the cursor. |
current | Object | The current highlighted feature. |
Click | function | The click method for the interaction. This will shortcircuit the getFeature method. |
noLocationClick | function | The noLocationClick method for the interaction, this is only ran if there is no current highlight interaction, and Click method is not available. This will shortcircuit the getFeature method. |
clicked | Boolean | The click method was recently called. |