openlayers6加載百度地圖偏移問題解決

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加載百度地圖偏移問題解決

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章