支持config.js中配置多层地图瓦片

pull/1641/head
Kairlec 2024-10-11 11:10:11 +08:00
parent 3e1f31dab4
commit 192e92f772
No known key found for this signature in database
GPG Key ID: DB5579BC03F05D3E
2 changed files with 17 additions and 13 deletions

View File

@ -59,25 +59,28 @@ export default {
maxZoom: mapParam.maxZoom || 19,
minZoom: mapParam.minZoom || 1,
});
let tileLayer = null;
let tileLayers = [];
if (mapParam.tilesUrl) {
tileLayer = new Tile({
const tilesUrls = Array.isArray(mapParam.tilesUrl) ? mapParam.tilesUrl : [mapParam.tilesUrl]
tilesUrls.forEach(tilesUrl => {
tileLayers.push(new Tile({
source: new XYZ({
projection: getProj("EPSG:3857"),
wrapX: false,
tileSize: 256 || mapParam.tileSize,
url: mapParam.tilesUrl
url: tilesUrl
})
}))
})
}else {
tileLayer = new Tile({
tileLayers.push(new Tile({
preload: 4,
source: new OSM(),
})
}))
}
olMap = new Map({
target: this.$refs.mapContainer, // ID
layers: [tileLayer], //
layers: tileLayers, //
view: view, //
controls:[ //
// new ZoomSlider(),

View File

@ -8,6 +8,7 @@ window.mapParam = {
// 坐标系 GCJ-02 WGS-84,
coordinateSystem: "GCJ-02",
// 地图瓦片地址
// 地图瓦片地址 , 支持string[]类型作为多层地图瓦片
tilesUrl: "http://webrd0{1-4}.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scale=1&style=8",
// 瓦片大小
tileSize: 256,