-
Notifications
You must be signed in to change notification settings - Fork 1.3k
LatLngBounds of visible region incorrect when map rotated #12135
Comments
Only the
|
Thanks for reporting this issue @kjkrum. I'm seeing that #11309 introduced this issue while fixing incorrect bounds generated by the builder when crossing IDL. @osana what do you think about bringing back the builder for the visible region bounds generation but fixing it over IDL instead of the solution proposed in #11309? I feel like it brings too much complication and another approach to doing the same thing. |
@LukasPaczos @kjkrum I believe the hard use case is when Map is very zoomed out showing almost the entire world with IDL in the middle and map is rotated. Using includes() as suggested above will not work as it will do the shortest bounds to include those points. I think we will have to use LatLngBounds.from() but it is not easy to figure out which value is north, south, east and west. |
MapboxMap.getProjection().getVisibleRegion().latLngBounds
is wildly incorrect when the map is rotated past a certain angle. The angle at which the calculation goes off the rails is the angle of the diagonal of theMapView
.To demonstrate this, in my camera idle listener, I get the
LatLngBounds
as above and draw a thick red polyline around their perimeter, removing the old polyline if present. When the map is oriented north-south, half the width of the polyline is visible all around the edge of the map, exactly as you would expect. When it's rotated less than the angle of the diagonal, just a bit of the polyline is visible in the corners, again as you would expect. But as soon as it's rotated past the angle of the diagonal, it's evident that east and west are being set from the wrong corners. In this screenshot, the west edge of the bounds is being set from the bottom right corner, when it should be the bottom left.Using 6.1.2. Also tested with 5.5.3.
The text was updated successfully, but these errors were encountered: