How to set the max and min zoom in a mapbox in Dash with Python?

I have a dash app with a map of country made in Python. Currently, it can zoom out to continent view and even world view. I want to restrict the zoom so that user cannot zoom out beyond the country view. Then can zoom in, however, as much as they want. How do I do this?

I found that the Mapbox GL JS library gives options to control the max and min zoom via options.minZoom and options.maxZoom. Is there any way to use these, or something similar, with Python?

I tried using these 2 parameters like so:

go.Scattermapbox(
	lat=df.Lat,
	lon=df.Lon,
	mode='markers',
	marker=go.scattermapbox.Marker(
		size=10,
		opacity=0.5,
		color=COLORS
	),
	maxZoom=20,
	minZoom=5
)

but it seems these 2 properties have not been implemented in the Plotly/Dash version of Mapbox:

ValueError: Invalid property specified for object of type plotly.graph_objs.Scattermapbox: 'maxZoom'

2 Likes

Hello,
Didi you finally find a solution to our issue? Iā€™m looking to block the zoom out as well
Cheers!

Same issue here, any updates or a workaround for this would be greatly appreciated.