Mapbox - how to select a point with mouse click

Hey there. I have included Mapbox in my app. I want it to work like: When i scroll through the map, on left/right click on any location, it should mark that point. On select "Modesto city airport", it should mark that point red(:round_pushpin:) on the map. So then that's a point.

Thanks for reading!

Hey @ltfrupdt!

The built-in map component doesn't support click handlers at the moment but a number of people have set up a custom component to display maps. Mapbox themselves have a nice quickstart here that you can explore. There are also a couple of examples folks have posted on the forums that include the full custom component code they're using.

Hopefully that's helpful, but let me know if you have any questions getting set up! Otherwise, we can let you know here if we do include click handlers for the built-in component :slightly_smiling_face:

If it does not support click and select a location or even not possible to mark the location in some way, how does one mark a point in the map?

You can dynamically pass a list of points in either of the Points or GeoJSON fields.

This can be useful for adding points via other elements in your UI e.g. a person selects a particular category of vendors in your app, and their locations are displayed on the map. However, it sounds like you're looking to have people interact directly with the map in order to select points and I think for that, a custom component might be the best way to go.

We would also like to have a click handler on the mapbox component. It would be great if this could be integrated. It should provide the latitude/longitude position on which was clicked.