//加载瓦片
// let extents = [105.4,36.82046936035156,105.9,37.78046936035156];
vm.map = new Map({
target: document.getElementById("mapDiv"),
controls: defaults({
zoom: false,
}),
view: new View({
// center: fromLonLat([105.68367004394531, 37.34046936035156]),
zoom: 10,
// extent: transformExtent(extents, 'EPSG:4326', 'EPSG:3857'),
maxZoom: 18,
minZoom: 10,
}),
});
let imgMap = new Tile({
source:new TileImage({
projection: 'EPSG:4326',
tileUrlFunction: function (tileCoord, pixelRatio, proj) {
let z = tileCoord[0];
let x = tileCoord[1];
let y = tileCoord[2];
// 百度瓦片服务url将负数使用M前缀来标识
if (x < 0) {
x = -x;
}
if (y < 0) {
y = -y;
}
try {
return require(`../../../../assets/images/map/img_c/${z}-${y - 1}-${x}.jpg`)
}catch (e) {
return require(`../../../../assets/images/map/img_c/10-147-808.jpg`)
}
}
})
});
本地加载瓦片地图
最新推荐文章于 2021-07-04 15:57:53 发布