简体   繁体   中英

OpenLayers caching quota

I'm using OpenLayers to cache map tiles. It uses LocalStorage as storage mechanism for the cached tiles. There is an event that fires when I run out of space (ie at 5MB), and I have the option of completely clearing or iterating the cache.

I am using LocalStorage to store other objects also, such as settings, so its not good if I run out of space.

How can I set a max limit for tiles cached by OpenLayers? Preferably as a size limitation (not number of items).

Good question. By reading the source code of the control this is not possible. You would have to modify the CacheWrite class to add a maxLimit property or something like that. Another solution would be to override the whole control and use HTML5 File API.

Use pouch db to store tiles. It will remove the 5mb limit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM