MapBox set visible points

Hello everyone,

I am trying to build a mapbox which only needs to showcase one point. The thing is that the mapbox resides in a form, and I don't know the marker that I want to show until I fetch some data from an API.

If I set the visible points in the UI, all is fine, however I cannot find a method in the mapbox which will update the markers dynamically. Can someone assist me?

I tried the following:

None of them would render the map and display the marker accordingly. Is there something I am doing wrong ?

This is the desired outcome that I would like, but the point to change dynamically based on a location that the user searches by name (I do know the coordinates)

Hi @Tudor33sud thanks for reaching out! Welcome to the community :tada:

Instead of hardcoding your Points data, you can dynamically reference the api query. It may look a bit different depending on how the data is structured, but I have an example below:

I have an api query that is triggered manually in my app and it will return an object with latitude & longitude.

Before it runs, will evaluate to null, and the map will load with no points:

When apiQuery gets triggered, the map will update dynamically with the new point data:

Let me know if that helps!