Mapbox fitBounds

Hi team- it looks like most of the properties around the mapbox component are configured to output map features based on user manipulation of the map. I'm trying to use it in the reverse manner; populate points onto the map based on other queries, and then zoom to display them. It's simple enough to populate the points, but I can't seem to find a great solution for zooming to fit. It looks like mapbox has a fitBounds function built it, but I'm not sure retool has it. Any ideas on a workaround?

Hi Jgaro!

I don't think the mapbox component has any direct controls for this, so the feature request here could be good!

The best workaround I can think of is using a temporary state and referencing the value in the Zoom setting of the map. You can then use a Run JS Code query to directly modify that value and change the zoom level of the map:

1 Like

Hey! Just want to give a quick update here for posterity, Retool now supports focusing the camera on GeoJson passed to the Mapbox component:


Attached is an example app that demonstrates how this might work!

GeoJSON focus (1).json (15.4 KB)

1 Like