Flutter_map: Tiles are not shown if used in another instance of FlutterMap

Created on 28 May 2020  路  6Comments  路  Source: fleaflet/flutter_map

For details look at the screen record from current version of example app.
To reproduce just start the example app and switch between 'MapController' and 'AnimatedMapController'. Unfortunately it鈥檚 blocking the app in my use case of FlutterMap because I push multiple instances of FlutterMap with ineractive: false to the navigation stack and you can just remove the 'grayscreen' by zooming in or out. Would be awesome to have a solution for that.

video-2020-05-28-16-56-41

Best Regards

bug

Most helpful comment

With flutter_map version 8, tiles are correctly displayed.
Seems that a commit from version 9 break something.
Need to explore git history and find the issue

EDIT: Commit d4aefaecc44d0c0b431375fd7bc97b2ef1a214e7 breaks tiles display
I'm going to write a PR to fix that

All 6 comments

I think it has something to do with the CachingNetworkTileProvider because the issue does not appear on the ZoomButtonPlugins Page and there the NonCachingNetworkTileProvider is used.

You may be able to fake it by adding a move or slightly changing the zoom to something and back again, which will force a refresh ?

Thanks for that hint. Thought about that earlier but didn't came back to it. Tried it now and works fine :) added the following code:

@override
  void didUpdateWidget(SimpleMapView oldWidget) {
    super.didUpdateWidget(oldWidget);
    if (widget.position != oldWidget.position || widget.zoom != oldWidget.zoom)
      _mapController?.move(widget.position, 18);
    Future.delayed(Duration(milliseconds: 200)).then(
      (value) => _mapController?.move(widget.position, widget.zoom),
    );
  }

EDIT:
As I found out it just works for coming back to the widget but not for coming first time to the widget, so for initState

With flutter_map version 8, tiles are correctly displayed.
Seems that a commit from version 9 break something.
Need to explore git history and find the issue

EDIT: Commit d4aefaecc44d0c0b431375fd7bc97b2ef1a214e7 breaks tiles display
I'm going to write a PR to fix that

@johnpryan PR available
Fix the race condition

PR #715 is an easy applicable fix, try it out.

Was this page helpful?
0 / 5 - 0 ratings