-
-
Notifications
You must be signed in to change notification settings - Fork 860
New issue
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
fitBounds does not work as expected when a Map is rotated #1342
Comments
I haven't tested this yet, but think this has been raised before and don't think there's any code to deal with it yet, so I think makes sense it wouldn't work. I think this will get done at some point, but pull requests welcome, to make it sooner! |
Try to set rotation to zero before fitbounds |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
I think have fixed this in my fork, still testing. My code looks slightly different, but it's a quick fix anyway. In
EDIT: The rotated bounding box approach works well when the layers fill the whole non-rotated bounds, but with vector layers for example, it feels a bit less intuitive to the untrained eye since the bounding box itself is not visible... The bounding box may have some transparent regions which this approach takes care to include, making a rotated fit a bit "loose"/too zoomed out. Maybe there is a smarter way, this was just the most straight-forward solution that came up from the top of my head... |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
What is the bug?
The aim of this example is to be able to fit the map to contain the four specified bounds. When the Fit Bounds button is clicked with no Map Rotation then it works as expected, but when a Map is first rotated and then the FitBounds button is pressed this is no longer the case.
What is the expected behaviour?
When a map is not rotated fitBounds works as expected
When a map is rotated then the map no longer shows all the bounds.
How can we reproduce this issue?
Do you have a potential solution?
While I don't have a solution I assume that there is a problem when calculating the new zoom value, as the problem occurs while using two of the methods in the MapController class.
In the MapState class (https://github.com/fleaflet/flutter_map/blob/master/lib/src/map/map.dart) both these methods use the getBoundsCenterZoom(LatLngBounds bounds, FitBoundsOptions options) function where the new center and zoom value are calculated. While the center is calculated correctly, the zoom (calculated by getBoundsZoom(LatLngBounds bounds, CustomPoint padding,{bool inside = false}) )value does not take into account that a map is rotated.
Can you provide any other information?
No response
Platforms Affected
Android
Severity
Minimum: Allows normal functioning
Frequency
Consistently: Always occurs at the same time and location
Requirements
flutter doctor
finds no relevant issuesThe text was updated successfully, but these errors were encountered: