We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
For many applications it would be good to be able to set bounds on where the user can pan and zoom mapbox maps: https://docs.mapbox.com/mapbox-gl-js/example/restrict-bounds/ and https://docs.mapbox.com/mapbox-gl-js/api/map/#map#setmaxzoom
The text was updated successfully, but these errors were encountered:
See also #3434 and the related cartesian #1876
Sorry, something went wrong.
I've come up with this as a python workaround, could be easily adaptable to js.
lats and longs are lists of all the coordinates.
`
zoom_lat = abs(abs(max(lats)) - abs(min(lats))) zoom_long = abs(abs(max(longs)) - abs(min(longs))) zoom_factor = max([zoom_lat,zoom_long]) if zoom_factor < 0.002: zoom_factor = 0.002 auto_zoom = -1.35 * math.log(float(zoom_factor)) + 7
I should mention this has only been tested for regional (USA) coordinates, I could see it needing modification when crossing hemispheres/equator
@archmoj I'm not sure if the bounds provide the same effect min/max zoom. Mapbox mention that there are some performance benefits by setting min/max zoom levels https://docs.mapbox.com/help/troubleshooting/mapbox-gl-js-performance/#filter-by-zoom-levels.
Successfully merging a pull request may close this issue.
For many applications it would be good to be able to set bounds on where the user can pan and zoom mapbox maps: https://docs.mapbox.com/mapbox-gl-js/example/restrict-bounds/ and https://docs.mapbox.com/mapbox-gl-js/api/map/#map#setmaxzoom
The text was updated successfully, but these errors were encountered: