相关文章推荐
开心的烤土司  ·  c# ...·  6 月前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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?

Found it, it's called project(LngLat)

pointInView = await map.project(foundAddress.center)

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

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.