访问Openlayers网站(https://jinuss.github.io/Openlayers_map_pages/,网站是基于
Vue3
+Openlayers
,里面有大量的实践和案例。觉得还不错,可以给个小星星Star,鼓励一波 https://github.com/Jinuss/OpenlayersMap哦~
概述
IconImageCache
类的目的是为了缓存图标图像及其相关的模式(pattern
),提高渲染性能,避免重复加载和创建图像。
源码分析
IconImageCache
类的源码实现
IconImageCache
的源码实现如下:
class IconImageCache {
constructor() {
this.cache_ = {
};
this.patternCache_ = {
};
this.cacheSize_ = 0;
this.maxCacheSize_ = 32;
}
clear() {
this.cache_ = {
};
this.patternCache_ = {
};
this.cacheSize_ = 0;
}
canExpireCache() {
return this.cacheSize_ > this.maxCacheSize_;
}
expire() {