vue中openlayers 加載離線瓦片地圖


記錄下,直接貼代碼吧

let roadLayer = new Group({
layers: [
new TileLayer({
source: new XYZ({
//url : 'http://mt3.google.cn/vt/lyrs=m&hl=zh-CN&gl=cn&x={x}&y={y}&z={z}', //這是加載線上谷歌地圖
tileUrlFunction: ($xyz) => { //引入離線瓦片
return require('@/assets/google/'+$xyz[0]+'/'+$xyz[1]+'/'+$xyz[2]+'.png');
},
minZoom : 17, 
maxZoom : 17 
})
}),
]
});
this.mapObj.view = new View({
projection: "EPSG:4326", //使用這個坐標系
center: this.mapObj.center,//[116.72429, 39.90468],//
extent: [116.74,39.9,117,39.89],// this.mapObj.extent, //[116.2, 35, 117.9999, 42.99]
zoom: this.mapObj.zoom,
minZoom: 17,
maxZoom: 17
});
this.map = new Map({
target: "map",
layers: [ roadLayer ],
overlays: [],
view: this.mapObj.view
});

 


免責聲明!

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



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