How to get features in openlayers with mapbox?

66 views Asked by At
1

There are 1 answers

0
Mike On BEST ANSWER

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