From 192e92f7720ed187c181543e86f93ce104966c26 Mon Sep 17 00:00:00 2001 From: Kairlec Date: Fri, 11 Oct 2024 11:10:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81config.js=E4=B8=AD=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=A4=9A=E5=B1=82=E5=9C=B0=E5=9B=BE=E7=93=A6=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/common/MapComponent.vue | 29 ++++++++++--------- web_src/static/js/config.js | 1 + 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/web_src/src/components/common/MapComponent.vue b/web_src/src/components/common/MapComponent.vue index fb091ad6..a6f2209d 100755 --- a/web_src/src/components/common/MapComponent.vue +++ b/web_src/src/components/common/MapComponent.vue @@ -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({ - source: new XYZ({ - projection: getProj("EPSG:3857"), - wrapX: false, - tileSize: 256 || mapParam.tileSize, - url: mapParam.tilesUrl - }) + 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: tilesUrl + }) + })) }) }else { - tileLayer = new Tile({ - preload: 4, - source: new OSM(), - }) + 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(), diff --git a/web_src/static/js/config.js b/web_src/static/js/config.js index 94a10569..1dc77412 100644 --- a/web_src/static/js/config.js +++ b/web_src/static/js/config.js @@ -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,