Open ryanhamley opened 6 years ago
User comment adding more background:
Yes, we were able to get the desired behavior using that workaround. Note that we also needed to set map.transform.maxValidLatitude = Infinity to be able to pan the map past the top and bottom edges of the container. That seems to be a related but separate issue from zooming to z0. Thanks for the help!
map.setMaxBounds(null); used to achieve this functionality so we could ensure that this function
This sounds good. But I'm wondering if this should be accomplished by doing https://github.com/mapbox/mapbox-gl-js/pull/6918 some other way. I haven't thought deeply about this but my gut instinct is that clamping latitude in the projection function is not the right way to approach this. Projecting { lat: 90, lng: 0 } returns the point at { lat: 85.051129, lng: 0 } and that doesn't seem right.
Would you propose clamping the value from 90 -> 85.051129 before projection happens? That would keep projection simpler and more predictable.
Yeah, making the bounds part of the code responsible for clamping sounds good to me and should let map.setMaxBounds(null)
have the old behavior without any special cases.
OK, this dovetails with some work I'm already doing on defining behavior for bounding boxes that cross the antimeridian so I'll take a look at changing this.
Motivation
https://github.com/mapbox/mapbox-gl-js/pull/6918 clamps latitude values to +-85.56° to prevent
fitBounds
values such as -90 from throwing an error. This inadvertently made zooming all the way out to z0 impossible. This should have been considered a breaking change. At least one user has already asked about this. Clamping latitudes to valid Web Mercator values is the correct behavior, but we should provide a simple API to allow a user to revert to the pre-v0.48.0 behavior.Design Alternatives
Do nothing. It can be argued that the previous behavior was a bug and we shouldn't add a way to reintroduce "buggy" behavior.
map.transform.latRange = null
achieves the desired effect without introducing a new APImap.setMaxBounds(null);
used to achieve this functionality so we could ensure that this function call sets thelatRange
tonull
We could add a map option such as
clampLatRange
with the defaulttrue
We could have an explicit
transform
method such asmap.transform.unclampLatRange()
.Design
The more I think about it, I might lean towards option 1. There's a way to achieve this without introducing a new API that allows arguably undesirable behavior. If we do want to implement this, I think 3 might be the simplest way for a user to allow this behavior.