Class: MapboxHoverInteraction

MapboxHoverInteraction

Interactions on a Mapbox map by highlighting features with a temporary layer. Automatically detects data layers and applies a yellow highlight by default.

new MapboxHoverInteraction(map, options)

MapboxViewer/infrastructure/adapters/interactions/MapboxHoverInteraction.ts, line 5

Creates a new MapboxHoverInteraction instance.

Name Type Description
map

The Mapbox map instance.

options

Configuration options for the hover interaction.

Methods

clearHoveredFeatures()

MapboxViewer/infrastructure/adapters/interactions/MapboxHoverInteraction.ts, line 225

Clears the list of hovered features.

disable()

MapboxViewer/infrastructure/adapters/interactions/MapboxHoverInteraction.ts, line 64

Disables the hover interaction by removing event listeners and cleaning up.

enable()

MapboxViewer/infrastructure/adapters/interactions/MapboxHoverInteraction.ts, line 56

Enables the hover interaction by attaching event listeners.

handleHover(e)

MapboxViewer/infrastructure/adapters/interactions/MapboxHoverInteraction.ts, line 127

Handles mouse move events to detect and highlight features.

Name Type Description
e

The map mouse event.

removeHighlightLayer()

MapboxViewer/infrastructure/adapters/interactions/MapboxHoverInteraction.ts, line 250

Removes the temporary highlight layer and source.

selectPriorityFeatures(features)

MapboxViewer/infrastructure/adapters/interactions/MapboxHoverInteraction.ts, line 92

Selects the highest priority feature from a collection based on geometry type. Priority order: Point > Line > Polygon. Returns only the first feature from the highest priority group.

Name Type Description
features

Array of features to filter.

Returns:
Array containing at most one feature with the highest priority geometry type.

setOptions(options)

MapboxViewer/infrastructure/adapters/interactions/MapboxHoverInteraction.ts, line 76

Updates the interaction options.

Name Type Description
options

New options to apply.