diff --git a/lib/src/layer/tile_layer/tile_layer.dart b/lib/src/layer/tile_layer/tile_layer.dart index b688e4aac..8cefce1ac 100644 --- a/lib/src/layer/tile_layer/tile_layer.dart +++ b/lib/src/layer/tile_layer/tile_layer.dart @@ -385,7 +385,16 @@ class _TileLayerState extends State with TickerProviderStateMixin { } if (reloadTiles) { - _updateTilesInVisibleBounds(mapState); + if (mapState.size == const CustomPoint(0, 0)) { + debugPrint('Size is zero, scheduling update in next frame.'); + WidgetsBinding.instance.addPostFrameCallback((_) { + debugPrint('Post-frame callback update, size is: ${mapState.size}'); + _updateTilesInVisibleBounds(mapState); + }); + } else { + debugPrint('Size is non-zero, triggering update.'); + _updateTilesInVisibleBounds(mapState); + } } _initializedFromMapState = true; @@ -468,6 +477,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { @override Widget build(BuildContext context) { final map = FlutterMapState.maybeOf(context)!; + debugPrint('TileLayer build (map size ${map.size})'); if (_outsideZoomLimits(map.zoom.round())) return const SizedBox.shrink(); @@ -529,6 +539,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { // Load new tiles in the visible bounds and prune those outside. void _updateTilesInVisibleBounds(FlutterMapState mapState) { + debugPrint('Updating tiles, map size: ${mapState.size}'); final tileZoom = _clampToNativeZoom(mapState.zoom); if (!_outsideZoomLimits(tileZoom)) { _loadTilesAndMarkForPruning( diff --git a/lib/src/map/flutter_map_state.dart b/lib/src/map/flutter_map_state.dart index b6039646f..e0e2bbbfc 100644 --- a/lib/src/map/flutter_map_state.dart +++ b/lib/src/map/flutter_map_state.dart @@ -1,13 +1,14 @@ +import 'dart:math' as math; + import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map/src/core/bounds.dart'; import 'package:flutter_map/src/gestures/gestures.dart'; import 'package:flutter_map/src/map/map.dart'; import 'package:flutter_map/src/map/map_state_widget.dart'; import 'package:latlong2/latlong.dart'; -import 'dart:math' as math; -import 'package:flutter_map/src/core/bounds.dart'; class FlutterMapState extends MapGestureMixin with AutomaticKeepAliveClientMixin { @@ -42,6 +43,7 @@ class FlutterMapState extends MapGestureMixin _bounds = _calculateBounds(); WidgetsBinding.instance.addPostFrameCallback((_) { + debugPrint('FlutterMapState post frame callback (calling onMapReady)'); options.onMapReady?.call(); }); } @@ -158,6 +160,8 @@ class FlutterMapState extends MapGestureMixin return LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { //Update on layout change + debugPrint( + 'FlutterMapState LayoutBuilder set size: (${constraints.maxWidth}, ${constraints.maxHeight})'); setSize(constraints.maxWidth, constraints.maxHeight); if (options.bounds != null &&