Appearance
Documentation / @geoverse/core-libre / registerBaiduProtocol
Function: registerBaiduProtocol()
ts
function registerBaiduProtocol(maplibre, options?): () => void;Defined in: packages/core-libre/src/sources/baiduProtocol.ts:501
注册百度协议(一次性全局副作用,须由使用者显式调用)。
Parameters
maplibre
addProtocol
(name, action) => void
removeProtocol?
(name) => void
options?
Returns
注销函数:removeProtocol 该协议并 disposeBaiduWorker(回收共享 Worker)
() => void
Example
ts
import maplibregl from 'maplibre-gl';
registerBaiduProtocol(maplibregl, { tileUrl: (x,y,z)=>`/baidu-tile/${z}/${x}/${y}` });
const unregister = registerBaiduProtocol(maplibregl, { tileUrl: (x,y,z)=>`/baidu-tile/${z}/${x}/${y}` });
// 卸载/页面销毁时:unregister(); // 注销协议并回收 Worker