当前位置:网站首页>Mapbox GL JS active map refresh method
Mapbox GL JS active map refresh method
2022-07-26 01:22:00 【GIS developer】
Mapbox The vector tile technology used has many advantages , Such as : You can set the style dynamically 、 Clearly displayed at different scales , Small amount of data, etc . But in Web When developing , One criticism is the refresh of vector tiles . After we change a vector tile , How to make the browser actively request new tiles , Instead of periodically asking . After the data source is updated , How to quickly display , It is a thing that affects the user experience .Mapbox It has its own caching mechanism , It is different from the caching mechanism that depends entirely on the browser . How to refresh tiles efficiently , There are two ways :
Mapbox GL JS V2 Above version
Mapbox GL JS 2.0 The above version provides relevant API
map.triggerRepaint();
triggerRepaint All layers on the map will be refreshed . You can refer to Official documents
Through the interior API Refresh
This method is also what my colleagues told me , Specifically, spit it out
const style = map.style;
const sourceCaches = style._sourceCaches;
if(sourceCaches){
["source name 1","source name 2"].forEach(item=>{
const cache = sourceCaches[`other:${
item}`];
if(cache){
cache.clearTiles();
}
})
}
In this way , You can check some of the maps source refresh , To a large extent , Reduce network requests , Avoid refreshing layers such as images . Currently in Mapbox GL JS2 The above version tests are available , The previous version has not been tested .
边栏推荐
- How to obtain the cash flow data of advertising services to help analyze the advertising effect?
- Kubernetes Pod启动流程
- 游戏思考17:寻路引擎recast和detour学习二:recast导航网格生成流程及局限性
- FreeBSD bNXT Ethernet driver source code reading record 2:
- Game thinking 17: Road finding engine recast and detour learning II: recast navigation grid generation process and limitations
- What should I do when my blog is attacked by hackers?
- NodeJS 基于 Dapr 构建云原生微服务应用,从 0 到 1 快速上手指南
- Jushi | Haitai Fangyuan appears at the 5th Digital China Construction Summit
- android sqlite先分组后排序左连查询
- 两阶段提交和三阶段提交
猜你喜欢

两阶段提交和三阶段提交

"Yuanqi Cola" is not the end point, "China Cola" is

格式化JS代码,调试JS代码

Docker advanced -mysql master-slave replication

PyCharm在创建py文件时自动添加头部注释

Codeforces Round #810 (Div. 2)A~C

【Code】剑指offer 03数组中重复的数字

What should I do when my blog is attacked by hackers?

FastJson 处理泛型

What if win11 cannot open its own anti-virus software? Win11's built-in anti-virus function cannot be turned on
随机推荐
Jushi | Haitai Fangyuan appears at the 5th Digital China Construction Summit
MulDA: A Multilingual Data Augmentation Framework for Low-Resource Cross-Lingual NER 阅读笔记
# 浏览器开发使用技巧
[RTOS training camp] I2C and UART knowledge and preview arrangement + evening class questions
光纤通信中信号劣化的原因
聚势|海泰方圆亮相第五届数字中国建设峰会
两阶段提交和三阶段提交
ORACLE——iSupplier 门户开票错误
How to obtain the cash flow data of advertising services to help analyze the advertising effect?
[Jizhong] July 16, 2022 1432. Oil pipeline
数据库系统原理与应用教程(057)—— MySQL 练习题
Transfer learning - getting started
FreeBSD bnxt以太网驱动源码阅读记录二:
《分布式微服务电商》专题(一)-项目简介
Case when of SQL
【纪中】2022.7.16 1432.输油管道
Tutorial on principles and applications of database system (055) -- MySQL query (XVII): usage of mathematical functions
Leetcode537. 复数乘法(可以,已解决)
换ip软件的用途很广及原理 动态IP更换的四种方法来保护网络隐私
[data mining] differences, advantages and disadvantages between generative model and discriminant model