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方法
詳情:https://www.giserdqy.com/secdev/openlayers/36281/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM