Replies: 1 comment 2 replies
-
Plugin author here. For discussion thread, please see toward the bottom of JaffaKetchup/flutter_map_tile_caching#29 (reply in thread). @bmason8 Out of interest, now I know you're using provider, that might be causing an issue. When you reset, does a blank frame flash? If it doesn't, it doesn't look like the call is being made. |
Beta Was this translation helpful? Give feedback.
-
I'm having an issue with successfully clearing map tiles when switch tile sets (default to satellite and vice versa) and wondering if anyone can help me out.
I've been using flutter_map for a year now along with map_map_tile_caching and it's been working great when I would just cache one type of tile (let's call them default) using
StorageCachingTileProvider.
Then when I would need to show satellite tiles, I would switchNonCachingNetworkTileProvider
and all 'default' tiles would get cleared without issue. I did it this way because the library only supported caching one style of tile. *This still works fyi (ie no lack of tile clearing issues).However, I've been wanting to cache two different styles of map (default and satellite) and now that
flutter_map_tile_caching 4.0.0-dev.7
is available I implemented that functionality. It works great however, when I switch map styles the previous map style remain in certain areas. I initially assumed it was aflutter_map_tile_caching
issue but was told to take a look at this thread (fleaflet/flutter_map#667). So I implemented the resetTiles strategy demonstrated in the example lib but it's not working for me. I'm wondering if I've simply implemented it incorrectly or if it's a potential bug.Here is how I'm implementing the tileProvider using mapbox (to be clear, everything else works great):
*also sorry for the formatting, I'm pulling my hair out trying to fix it but have no idea why it looks like it does.
MAP_VIEW PAGE:
FlutterMap( mapController: _mapControlNotifier.mapController, options: _mapControlNotifier.mapOptions(context), children: [ TileLayerWidget(options: _mapControlNotifier.getCachingTileLayerOptions()), ], ),
MAP_CONTROL_NOTIFIER CLASS
`TileLayerOptions getCachingTileLayerOptions() {
}`
I set up the stream controller a little differently because I'm using a ChangeNotifier.
late StreamController<Null> resetController;
Then in a setup() function that gets run before the map tiles are loaded I initialize it.
resetController = StreamController.broadcast();
And then I run _resetTiles() when the user presses the 'Swap tile layers' button.
void _resetTiles() { layerToggle = !layerToggle; notifyListeners(); resetController.add(null); }
I've also tried a few different things to see if I'm doing something else wrong and none of them made any difference.
Any help would be greatly appreciated. I've been in contact with the dev from the
flutter_map_tile_caching
package and although it seems like it's a mistake I'm making or potentially aflutter_map
bug, he'll be taking another look at it sometime soon when he does some more testing.I'm really hoping it's just a stupid mistake I'm making but I haven't figured it out yet so please let me know if you have any ideas for me to try.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions