openlayers6加載百度地圖偏移問題解決
標題功能說明
openlayers升級到6版本後,3、4、5版本加載百度地圖的代碼,加載的地圖發生了偏移,原始代碼和偏移情況如下
let baiduSource = new TileImage({
projection: projection,
tileGrid: tilegrid,
tileUrlFunction: function (tileCoord, pixelRatio, proj) {
if (!tileCoord) {
return '';
}
let z = tileCoord[0];
let x = tileCoord[1];
let y = tileCoord[2];
return "http://online1.map.bdimg.com/onlinelabel/?qt=tile&x=" +
x + "&y=" + y + "&z=" + z +
"&styles=pl&scaler=1&udt=20191119";
},
crossOrigin: 'anonymous'
});
###解決方案
修改tileUrlFunction方法
詳情:openlayers6加載百度地圖偏移問題解決