From fd441f296727fe7638b5ea7d9d98ad42633f044a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BB=95=E5=B5=A9?= <17854119262@163.com> Date: Fri, 17 Jan 2025 16:22:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AD=A3=E5=BC=8F=E7=8E=AF=E5=A2=83=E4=BA=91?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=8F=A0=E5=8A=A0=E5=9B=BE=E7=89=87=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BasicQuery/ModalMap/index.vue | 162 +++++++++++------- .../CloudQueryModal/BasicQuery/index.vue | 5 +- 2 files changed, 97 insertions(+), 70 deletions(-) diff --git a/src/components/CloudQueryContent/CloudQueryModal/BasicQuery/ModalMap/index.vue b/src/components/CloudQueryContent/CloudQueryModal/BasicQuery/ModalMap/index.vue index dc17f375..d430a799 100644 --- a/src/components/CloudQueryContent/CloudQueryModal/BasicQuery/ModalMap/index.vue +++ b/src/components/CloudQueryContent/CloudQueryModal/BasicQuery/ModalMap/index.vue @@ -64,6 +64,100 @@ } const initMap = () => { + let mapDataSources: any = + networkType.value == 'LAN' + ? { + 'raster-tiles': { + type: 'raster', + tiles: [ + `http://t0.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=${MapboxConfig.TDT_TOKEN}`, + ], + tileSize: 256, + minzoom: 1, + maxzoom: 17, + }, + 'raster-tiles-font': { + type: 'raster', + tiles: [ + `https://t0.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=${MapboxConfig.TDT_TOKEN}`, + ], + tileSize: 256, + }, + yaogan: { + type: 'raster', + tiles: [VITE_GLOB_YAOGANYINGXIANG_SERVER], + tileSize: 256, + minzoom: 16, + maxzoom: 24, + }, + yingxiang: { + type: 'raster', + tiles: [VITE_GLOB_YINGXIANG_SERVER], + tileSize: 256, + minzoom: 16, + maxzoom: 24, + }, + } + : { + 'raster-tiles': { + type: 'raster', + tiles: [ + `http://t0.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=${MapboxConfig.TDT_TOKEN}`, + ], + tileSize: 256, + minzoom: 1, + maxzoom: 17, + }, + 'raster-tiles-font': { + type: 'raster', + tiles: [ + `https://t0.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=${MapboxConfig.TDT_TOKEN}`, + ], + tileSize: 256, + }, + }; + + let mapDataLayers: any = + networkType.value == 'LAN' + ? [ + { + id: 'tdt-vec-tiles', + type: 'raster', + source: 'raster-tiles-font', + }, + { + id: 'tdt-img-tiles', + type: 'raster', + source: 'raster-tiles', + }, + { + id: 'yaogan', + type: 'raster', + source: 'yaogan', + minzoom: 9, + maxzoom: 15, + }, + { + id: 'yingxiang', + type: 'raster', + source: 'yingxiang', + minzoom: 13, + maxzoom: 24, + }, + ] + : [ + { + id: 'tdt-vec-tiles', + type: 'raster', + source: 'raster-tiles-font', + }, + { + id: 'tdt-img-tiles', + type: 'raster', + source: 'raster-tiles', + }, + ]; + return new mapboxgl.Map({ container: mapId, language: 'zh-cmn', @@ -71,72 +165,8 @@ style: { glyphs: 'mapbox://fonts/mapbox/{fontstack}/{range}.pbf', version: 8, - sources: { - 'raster-tiles': { - type: 'raster', - tiles: [ - `http://t0.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=${MapboxConfig.TDT_TOKEN}`, - ], - tileSize: 256, - minzoom: 1, - maxzoom: 17, - }, - 'raster-tiles-font': { - type: 'raster', - tiles: [ - `https://t0.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=${MapboxConfig.TDT_TOKEN}`, - ], - tileSize: 256, - }, - yaogan: { - type: 'raster', - tiles: [VITE_GLOB_YAOGANYINGXIANG_SERVER], - tileSize: 256, - minzoom: 16, - maxzoom: 24, - }, - yingxiang: { - type: 'raster', - tiles: [VITE_GLOB_YINGXIANG_SERVER], - tileSize: 256, - minzoom: 16, - maxzoom: 24, - }, - }, - layers: [ - { - id: 'tdt-vec-tiles', - type: 'raster', - source: 'raster-tiles-font', - maxZoom: 32, - }, - { - id: 'tdt-img-tiles', - type: 'raster', - source: 'raster-tiles', - maxZoom: 32, - }, - { - id: 'yaogan', - type: 'raster', - source: 'yaogan', - layout: { - visibility: networkType.value == 'LAN' ? 'visible' : 'none', - }, - minzoom: 9, - maxzoom: 15, - }, - { - id: 'yingxiang', - type: 'raster', - source: 'yingxiang', - layout: { - visibility: networkType.value == 'LAN' ? 'visible' : 'none', - }, - minzoom: 13, - maxzoom: 24, - }, - ], + sources: mapDataSources, + layers: mapDataLayers, }, maxZoom: 22, minZoom: 8, diff --git a/src/components/CloudQueryContent/CloudQueryModal/BasicQuery/index.vue b/src/components/CloudQueryContent/CloudQueryModal/BasicQuery/index.vue index 9e450468..c87537aa 100644 --- a/src/components/CloudQueryContent/CloudQueryModal/BasicQuery/index.vue +++ b/src/components/CloudQueryContent/CloudQueryModal/BasicQuery/index.vue @@ -353,11 +353,8 @@ // 添加新的源和图层 map.addSource('radar', { type: 'image', - url: url, + url: dataURL, coordinates: fourpoint, - paint: { - 'raster-opacity': 1, - }, }); map.addLayer({ id: 'radar-layer',