1

Firstly, I am using the mapRef to get the vanilla API for mapbox for use.

I am using turf.js to calculate the bbox from a polygon feature gotten when I draw a polygon on a layer using Mapbox Draw. After conversion, I use queryRenderedFeatures like so:

const features = drawRef && drawRef.getFeatures();
    const geometry = features && features[0];
    console.log(features);
    const bbox = geometry && turf.bbox(features[0]);

    console.log(
      bbox && map.queryRenderedFeatures({ bbox, layers: ["mexs"] })
    );

I constantly seem to get an empty array with the above code. However, when I replace the 'bbox' parameter with a point in the queryRenderedFeatures function, I get the layer properties. What am I doing wrong, please? Help me

Nate
  • 11
  • 2
  • queryRenderedFeatures expects the first parameter to be in pixels and turf.bbox returns an array of coordinates – Anatolii Suhanov Oct 27 '20 at 19:22
  • Oh I see. Is there any way, you know that I can query the rendered features of a layer according to the bounding box in coordinates? – Nate Oct 29 '20 at 13:42

0 Answers0