JaffaKetchup / flutter_map_tile_caching

Plugin for flutter_map providing advanced & performant caching and bulk downloading functionality, with many options for region shapes and extra tools
https://pub.dev/packages/flutter_map_tile_caching
GNU General Public License v3.0
118 stars 72 forks source link

[BUG] Tiles not cached from not visible TileLayer ? #92

Closed Mmisiek closed 1 year ago

Mmisiek commented 1 year ago

What is the bug?

So I have a map which is using two TileLayers (one visible at the time). I added functionality to cache region to two separate stores based on separate TileLayer definitions. I first download first layer and when done the second. Somehow only first is cached and second is not.

What is the expected behaviour?

Both TileLayers cached not only the one currently visible on the map.

How can we reproduce this issue?

Map with 2 TileLayers based on value of boolean.

Do you have a potential solution?

Nope.

Can you provide any other information?

No response

Platforms Affected

Android, iOS, Windows

Severity

Erroneous: Prevents normal functioning and causes errors in the console

Frequency

Consistently: Always occurs at the same time and location

Requirements

JaffaKetchup commented 1 year ago

Hey @Mmisiek, Can you create a minimal reproducible example please, so I can understand your exact setup better? Thanks for the report!

Mmisiek commented 1 year ago

Hello, So I spent some time and created example https://github.com/Mmisiek/map_tile_cache_test (Un)fortunatley this one works as expected. The idea is to show "Satellite" then "Save View" go to Airplane mode and show "Streets". In my large app they do not show up like db is missing or else. How to check if tiles of not visible layer were downloaded ? Thanks for great plugin anyway !

JaffaKetchup commented 1 year ago

Hey @Mmisiek, There's a method to check if a tile is cached: https://fmtc.jaffaketchup.dev/usage/integration#check-if-a-tile-is-cached. You can use FM's tileBuilder property in a TileLayer, and consume the result of this function to display the tile with different color overlays, similar to as is done in the example app's downloader page. Please let me know if you need more help :)

adnan-haider007 commented 6 hours ago

i have a question which is i want to cache tile layer for satellite map but its not visible on offline mode even downloaded , here is my code where I use to download tile layer


  return FMTCStore('mapStore').getTileProvider(
      settings: FMTCTileProviderSettings(
    behavior: CacheBehavior.cacheFirst,
    maxStoreLength: 100000,
    errorHandler: (exception) {
      debugPrint("Cache error: ${exception.message}");
      // Log the URL for the failing tile request
      debugPrint("Failed URL: ${exception.type}");
    },
    cachedValidDuration: Duration(days: 90),
  ));
}```
 is any idea why its not working.
JaffaKetchup commented 2 hours ago

@adnan-haider007 Please open a new issue and include as much information and explanation as possible. I will be unable to be of much help with the current information.