All pages
Powered by GitBook
1 of 3

Loading...

Loading...

Loading...

Interactions


The Interactions module allows you to be notified when the user interacts with the map.

Interactions include clicking and hovering on points and features.

Controller

  • InteractionsController

Interfaces

MapInteractionEvent

InteractionsController


The Interactions controller allows you to observe interactions with the map

Extended by

  • FeltController

Events

onPointerClick()

onPointerClick(params: { handler: (event: ) => void; }): VoidFunction

Allows you to be notified when the user clicks on the map.

Use this to react to user clicks on the map, such as triggering custom actions or collecting interaction data.

Parameters

Parameter
Type

Returns

VoidFunction

A function to unsubscribe from the listener.

Example


onPointerMove()

onPointerMove(params: { handler: (event: ) => void; }): VoidFunction

Allows you to be notified when the user moves the mouse over the map.

Use this to track mouse movement and detect features under the cursor, such as for hover effects or real-time data display.

Parameters

Parameter
Type
Description

Returns

VoidFunction

A function to unsubscribe from the listener.

Example

MapInteractionEvent


The event object passed to the interaction listeners.

Properties

coordinate

coordinate: LatLng

The cursor position in world coordinates.


point

point: { x: number; y: number; }

The pixel coordinates of the mouse cursor, relative to the map and measured from the top left corner.

Name
Type

x

number

y

number


features

features: LayerFeature[]

The vector features that are under the cursor.


rasterValues

rasterValues: RasterValue[]

The raster pixel values that are under the cursor.

params

{ handler: (event: MapInteractionEvent) => void; }

params.handler

(event: MapInteractionEvent) => void

params

{ handler: (event: MapInteractionEvent) => void; }

Params for the listener

params.handler

(event: MapInteractionEvent) => void

The handler function

MapInteractionEvent
MapInteractionEvent
const unsubscribe = felt.onPointerClick({
  handler: (event) => console.log(event.center, event.features),
});

// later on...
unsubscribe();
// Track mouse movement and features under cursor
const unsubscribe = felt.onPointerMove({
  handler: (event) => {
    console.log("Mouse position:", event.center);
    console.log("Features under cursor:", event.features);
  }
});

// later on...
unsubscribe();