mapbox url中xyz处理
栅格图片时:raster
1:x,y,z如果栅格图片访问源有xyz,会自动处理切割, 当有多个x,y,z时,默认只会识别一个xyz,此时map有一个属性 transformRequest ,可以对url 作出处理
window.map = new window.SFMap.Map({
container: this.id,
minZoom: minZoom,
maxZoom: maxZoom,
style: style,
center: center,
zoom: zoom,
hash: false,
maxTileCacheSize: 32768,
fadeDuration: 0,
transformRequest: (url, resourceType) => {
if (resourceType === 'Tile' && url.startsWith('https://obs-tilemap.obs.cn-north-4.myhuaweicloud.com')) {
let urlArr=url.split("/")
// urlArr[urlArr.length-3]=this.getDate();
urlArr[urlArr.length-1]= urlArr[urlArr.length-1].replace('{z}', urlArr[urlArr.length-2]);
return {
url: urlArr.join("/"),
headers: {"Accept": "image/webp,image/apng,image/*,*/*;q=0.8"},
//credentials: 'include' // Include cookies for cross-origin requests
}
}
}
})