1.0.0 • Published 7 months ago
leaflet.tilelayer.tilefetch v1.0.0
Leaflet.TileLayer.TileFetch
使用自定义Fetch请求获取瓦片图层;
基于TileLayer的参数,增加了tileRequestParameters
参数,该参数为fetch()方法的初始化参数,支持function以及字面量形式
安装
npm install leaflet.tilelayer.tilefetch
引用
import "leaflet.tilelayer.tilefetch"
示例
参考example/index.html;
L.TileLayer.tileFetch(
'https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
{
tileRequestParameters: ()=>{
return {
cache:"default",
mode:'cors',
headers: {
'time': new Date().toISOString()
},
};
}
}
).addTo(map);
或者字面量形式
L.TileLayer.tileFetch(
'https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
{
tileRequestParameters: {
cache:"default",
mode:'cors',
headers: {
'token': 123
}
}
}
).addTo(map);
1.0.0
7 months ago