Skip to content
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

Force move to pick center even if max bounds does not fit #1331

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/src/map/map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,20 @@ class MapState {
}

// Try and fit the corners of the map inside the visible area.
// If it's still outside (so response is null), don't perform a move.
// If it's still outside (so response is null) and the map as already been
// drawn do nothing, otherwise on first pass adjust zoom to either fit
// the options.maxZoom or draw at max zoom with allowing map to draw
// ouside boundaries to avoid center never being set. In this state the map
// is not movable except to rotate.
if (options.maxBounds != null) {
final adjustedCenter =
LatLng? adjustedCenter =
adjustCenterIfOutsideMaxBounds(center, zoom, options.maxBounds!);
if (adjustedCenter == null && _lastCenter == null) {
final centerZoom = getBoundsCenterZoom(options.maxBounds!,
FitBoundsOptions(inside: true, maxZoom: options.maxZoom ?? 17));
adjustedCenter = centerZoom.center;
zoom = centerZoom.zoom;
}
if (adjustedCenter == null) {
return false;
} else {
Expand Down