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
});

猜你喜欢

转载自www.cnblogs.com/fmixue/p/12919361.html