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',