简体   繁体   English

OpenLayers缓存配额

[英]OpenLayers caching quota

I'm using OpenLayers to cache map tiles. 我正在使用OpenLayers来缓存地图图块。 It uses LocalStorage as storage mechanism for the cached tiles. 它使用LocalStorage作为缓存切片的存储机制。 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. 当我用完空间(即5MB)时会发生一个事件,我可以选择完全清除或迭代缓存。

I am using LocalStorage to store other objects also, such as settings, so its not good if I run out of space. 我也使用LocalStorage来存储其他对象,比如设置,所以如果我的空间不足就不好了。

How can I set a max limit for tiles cached by OpenLayers? 如何为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. 您必须修改CacheWrite类以添加maxLimit属性或类似的东西。 Another solution would be to override the whole control and use HTML5 File API. 另一种解决方案是覆盖整个控件并使用HTML5 File API。

Use pouch db to store tiles. 使用pouch db存储瓷砖。 It will remove the 5mb limit. 它将删除5mb限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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