2
votes

I found an address with the Mapbox Geocoding API. Then I want to highlight that building on the map.

It works in native, but does not in web. I want to have the point in the mapBox view for the renderedFeatures.

Something like this

pointInView = await map.getPointInView(foundAddress.center)
foundBuildings = await map.queryRenderedFeaturesAtPoint(pointInView)

How can I convert long,lat to the a point in mapbox-gl-js

Update Found something helpful How can I query the feature that's closest to the geocode result in Mapbox?

1

1 Answers

2
votes

Found it, it's called project(LngLat)

pointInView = await map.project(foundAddress.center)

See: https://docs.mapbox.com/mapbox-gl-js/api/#map#project