Skip to content

[Feat] Support New Mapbox GL JS Interactions API (v3.9.0+) #2551

@oisinlavery-renewhome

Description

@oisinlavery-renewhome

Target Use Case

Mapbox GL JS v3.9+ adds a new Interactions API (map.addInteraction() / map.removeInteraction()) for handling events declaratively on layers, featuresets, or the whole map.

This would remove the map.on/off boilerplate and make interactions reactive with props/state.

Proposal

It’d be great if react-map-gl exposed a simple component/hook for this, e.g.:

<Interaction
  type="click"
  target={{ layerId: 'my-layer' }}
  onEvent={(e) => console.log(e.feature)}
/>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions