-
-
Notifications
You must be signed in to change notification settings - Fork 860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support of storage tile caching #564
Conversation
# Conflicts: # example/lib/widgets/drawer.dart
Very nice! Works for me like a charm in IOS emulator. |
Will this work with a TileLayer that changes its URL template? I’ve got an app that switches between layers of data, using a different urlTemplate. Also for authenticated users I need to set a header for each tile request, but can’t seem to see how. |
Love this way of caching the tiles and a nice workaround for #636 |
Works great for me on an iPhone XR. Thank you for putting in the work. This would be a great feature to add! |
content: Text( | ||
'Cache db size: ${currentCacheSize.toStringAsFixed(2)} mb.' | ||
'\nCached tiles amount: $currentCacheAmount' | ||
'\nSeriosly want to delete this stuf?'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest changing these two lines:
'\nCached tiles amount: $currentCacheAmount'
'\nSeriosly want to delete this stuf?'),
to
'\nCached tiles count: $currentCacheAmount'
'\nAre you sure you want to clear cached tiles?'),
is this something that could be added as a separate package? I would like to encourage a more decentralized approach to plugins and tile providers |
Happy to add any packages to the README |
Hello. |
Hi all, This repo seems to have no maintainers, which is bad because there are many useful (and important to me) pull requests such as this and the null-safety migration (#829). So, I'm hoping that once that new flutter_map has been published, it will have active maintainers and you may have better luck merging this PR there. Also, this will mean changing this package to be null-safe, but I think that's probably the aim in the long run anyway. For me, this is a waiting game, as both this and the null-safety versions are important to me. Thanks, and I hope this repo (or some version of it) becomes active again soon, with all these new features. |
@JaffaKetchup TLDR: You can also use an existing ImageProvider cache like cached_network_image or network_to_file_image and supply the image provider like this: class CachedTileProvider extends TileProvider {
const CachedTileProvider();
@override
ImageProvider getImage(Coords<num> coords, TileLayerOptions options) {
return YourCachedNetworkImageProvider(
url: Uri.parse(getTileUrl(coords, options)),
);
}
} This repo is unlikely to get merged. @johnpryan appears to be wanting to remove large dependencies like sqflite and moving those to separate plugins (that anyone can make and maintain). This allows for flutter_map to be updated more frequently and be less monolithic. I agree with this methodology and am just using a custom image caching solution that I prefer over this implementation or the old implementation anyways. This pr should be closed and moved into an independent plugin or people who want the feature can use existing imageprovider caching plugins. There is no reason to reinvent the wheel especially for something that is so complex and use-case specific like image caching. |
Hi @moonag, |
Hi, @bugDim88. We would like to keep the core package small and reduce external dependencies. If you have a package that provides this custom tile provider I could add it to the README. Thanks! |
Hi all, |
@JaffaKetchup You don't need to make a plugin for flutter_map specifically as it is trivial to add it yourself using an image caching plugin. See my image above for using an existing caching solution like cached_network_image. There is a tutorial in the readme in master now too. If you have any questions I can help you set it up. If you are already using an image caching plugin like cached_network_image or network_to_file_image just create a new class like this and replace class CachedTileProvider extends TileProvider {
const CachedTileProvider();
@override
ImageProvider getImage(Coords<num> coords, TileLayerOptions options) {
return YourCachedNetworkImageProvider(
url: Uri.parse(getTileUrl(coords, options)),
);
}
} |
Hi @moonag and all, Yes, I can see I feel strongly about this reading this back to myself, but I still agree with it. If anyone wants to allow me to make a plugin out of this, I will happily do so, giving full credit to you guys 👍 . Best wishes, |
The direction I would like to head in is to keep the core package small with as few package dependencies as possible. When we add a package dependency (like |
Hi @johnpryan, |
@JaffaKetchup can you explain more what you mean? |
@johnpryan So, what I'm suggesting is converting this PR that would alter the main code and dependencies of this project to another plugin, like flutter_map_location_marker, for example. This would allow developers the choice of using this, prevent addition of more dependencies to the main code, but also allow easy integration of something like this, instead of developers having to code it themselves. |
It sounds like we agree that we want to encourage users to use whichever tile provider they like by adding a package dependency in their pubspec. I don't know quite what you mean when you say you would like to alter the main code and dependencies of this project and keep extra functions? |
Sorry, I guess I'm not being clear. I would not like to alter the code of this repo in any way, except to add another plugin link to the README (when/if this gets converted). What I was asking 2 hours ago after your comment was if there were any plans to make this a plugin, or if we were just going to leave this alone and waste the effort and code. If no-one wants to make this a plugin, I am happy to, and as I've said, I will give full credit to the real people who developed this code, @bugDim88 and @m-skolnick. And also, I apologise, I completely forgot about the "is this something that could be added as a separate package? I would like to encourage a more decentralized approach to plugins and tile providers" comment, :'D. If I'd realised this, I'd have offered sooner! |
Hi, |
Hi all, |
@JaffaKetchup We will be exploring offline maps in the next few months. When we get to that point, I'm sure your package will be extremely useful! |
@JaffaKetchup Very interested in the pre-loading of tiles as I had do do some workarounds in my app for that. Hopefully your solution is a neater one. Will test as soon as I have time. |
@JaffaKetchup feel free to add to the README! |
Thanks, I've opened the PR: #869. I've also just published it to pub.dev! https://pub.dev/packages/flutter_map_tile_caching |
Hello, this PR provides
TileProvider
that stores tile images on disk.PR has two new main classes:
StorageCachingTileProvider
- tile provider that automatically switches the network and local tile source. Basic logic is if local tile has expired update period (which you can define) than provider grabs this tile from network and updates local db row with that image, else provider takes local tile.TileStorageCachingManager
- singleton with static api for local db managing.StorageCachingTileProvider
uses this class under the hood for local tiles.Features:
Look at
AutoCachedTilesPage
in example folder for more info.Also PR has corresponding changes to
README.md
Note: for local db
TileStorageCachingManager
uses sqflite,not tested on IOS devices.
closes #279, #170, #276