-1

I try to do it but it doesn't work, below is my main code.

enter image description here

enter image description here

Finn
  • 3
  • 1

1 Answers1

0

You need to query the features on the Mapbox map

map.on('click', (e) => {
  const point = new mapboxgl.Point(e.pixel[0], e.pixel[1]);
  const features = mbMap.queryRenderedFeatures(point);
  console.log(features);
});

https://codesandbox.io/s/mapbox-layer-forked-x8mocy?file=/main.js

Mike
  • 16,042
  • 2
  • 14
  • 30