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

Parameters:
NameTypeDescription
eObject

The calling event.

(inner) featureCallback(F, L)

The featureCallback method is provided as function argument with the layer filter and pixel hit tolerance options to Openlayers forEachFeatureAtPixel method. The featureCallback method will assign features as candidates for the highlight interaction to the interaction.candidates{} object.

Parameters:
NameTypeDescription
FObject

The OL Feature object.

LObject

The OL Layer object.

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

Parameters:
NameTypeDescription
featureObject

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.

Parameters:
NameTypeDescription
paramsobject

The params object is spread into the interaction defaults.

Properties
NameTypeAttributesDescription
getLocationfunction<optional>

Will be executed after the getFeature method.

(inner) layerFilter(L)

The layerFilter method filters mapview layers with a qID.

Parameters:
NameTypeDescription
LObject

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 remove longClick state when the map is panned.

The interaction.candidates{} object is reset to empty.

The featureCallback method which assigns features to the interaction.candidates{} object is passed as callback argument to the forEachFeatureAtPixel method with the interaction.layerFilter and interaction.hitTolerance in the options argument.

The highlight will be cleared and the method will shortcircuit if no candidate feature has been found at the pixel.

A feature which is not in the interaction.candidateKeys will be identified. The candidates are assumed to be the same as the candidateKeys set if all candidates are in the set and the length is the same. The method will shortcircuit in this case. Otherwise the candidateKeys set will be assigned from the candidates object keys.

The first key from candidates object keys will be assigned as the candidateKey if yet undefined and the set is not the same.

The feature is now assigned from the candidates object identified by the candidateKey.

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.

Parameters:
NameTypeDescription
eObject

The pointerMove event.

Properties
NameTypeDescription
e.pixelObject

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.

Type:
  • Object
Properties
NameTypeDescription
getFeaturefunction

Method to return a feature from the highlight or click event methods.

longClickMethodfunction

Defaults to mapview.allFeatures()

longClickTimeoutNumber

Timeout for the execution of the longClickMethod.

longClickMSInteger

Milliseconds for longClickTimeout. Defaults to 500ms.

longClickBoolean

Execute longClick method.

hitToleranceNumber

Pixel distance for detection of features on pixel. Defaults to 5pixel.

candidateKeysSet

A set of candidate features under the cursor.

currentObject

The current highlighted feature.

Clickfunction

The click method for the interaction. This will shortcircuit the getFeature method.

noLocationClickfunction

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.

clickedBoolean

The click method was recently called.