Skip to content

Commit

Permalink
Fix bounds/fitBounds not working on first display. (#1413)
Browse files Browse the repository at this point in the history
* fix for broken bounds/fitBounds when it has a size of 0 (web ok, mobile not as faster)

* dart formatting
  • Loading branch information
ibrierley authored Dec 11, 2022
1 parent 77cf06d commit 89f6c2b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/src/map/flutter_map_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,16 @@ class FlutterMapState extends MapGestureMixin
},
);


return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
//Update on layout change
setSize(constraints.maxWidth, constraints.maxHeight);

if (options.bounds != null && !_hasFitInitialBounds) {
final target = getBoundsCenterZoom(options.bounds!, options.boundsOptions);
if (options.bounds != null &&
!_hasFitInitialBounds &&
constraints.maxWidth != 0.0) {
final target =
getBoundsCenterZoom(options.bounds!, options.boundsOptions);
_zoom = target.zoom;
_center = target.center;
_hasFitInitialBounds = true;
Expand Down

0 comments on commit 89f6c2b

Please sign in to comment.