Преглед изворни кода

图层配置封装到配置文件中

sbj пре 1 година
родитељ
комит
51e95a26e1
2 измењених фајлова са 125 додато и 90 уклоњено
  1. 31 0
      src/config/layerConfig.js
  2. 94 90
      src/utils/map/Layer.js

+ 31 - 0
src/config/layerConfig.js

@@ -0,0 +1,31 @@
+module.exports = {
+    digitalTwinLayer: 'http://10.83.68.109:6080/arcgis/rest/services/digitalTwain_3857/MapServer',
+    waterPassengerLayer: 'http://10.83.68.109:6080/arcgis/rest/services/water_passenger_3857/MapServer',
+    ghjgCxAllLayer: 'http://10.83.68.109:6080/arcgis/rest/services/ghjg_cxall/MapServer',
+    jjqLayer: 'http://10.83.68.109:6080/arcgis/rest/services/jingjiequ/MapServer',
+    jjqIconLayer: 'https://ghjg.china-gis.com/server/rest/services/Hosted/警戒区图标/SceneServer',
+    dtqLayer: 'http://10.83.68.109:6080/arcgis/rest/services/backArea/MapServer',
+    dtqIconLayer: 'https://ghjg.china-gis.com/server/rest/services/Hosted/掉头区图标/SceneServer',
+    mdLayer: 'http://10.83.68.109:6080/arcgis/rest/services/maodi/MapServer',
+    mdIconLayer: 'https://ghjg.china-gis.com/server/rest/services/Hosted/锚地图标/SceneServer',
+    sszhLayer: 'http://10.83.68.109:6080/arcgis/rest/services/shuishangfuququ/MapServer',
+    sszhIconLayer: 'https://ghjg.china-gis.com/server/rest/services/Hosted/水上绿色综合服务区图标/SceneServer',
+    hbLayer: 'https://ghjg.china-gis.com/server/rest/services/Hosted/航标/SceneServer',
+    sxdxLayer202301: 'https://ghjg.china-gis.com/server/rest/services/Hosted/多波束/SceneServer',
+    sxdxLayer202201: 'https://ghjg.china-gis.com/server/rest/services/Hosted/第一期2022/SceneServer',
+    sxdxLayer202202: 'https://ghjg.china-gis.com/server/rest/services/Hosted/第二期2022/SceneServer',
+    sxdxLayer202101: 'https://ghjg.china-gis.com/server/rest/services/Hosted/第一期2021/SceneServer',
+    sxdxLayer202102: 'https://ghjg.china-gis.com/server/rest/services/Hosted/第二期2021/SceneServer',
+    sxdxLayer202001: 'https://ghjg.china-gis.com/server/rest/services/Hosted/第一期2020/SceneServer',
+    sxdxLayer202002: 'https://ghjg.china-gis.com/server/rest/services/Hosted/第二期2020/SceneServer',
+    labmhPJ500Layer: 'https://ghjg.china-gis.com/server/rest/services/Hosted/黄浦江周边建筑500m/SceneServer',
+    labmPxLayer: 'https://ghjg.china-gis.com/server/rest/services/Hosted/浦西核心段白膜/SceneServer',
+    lajmLayer: 'https://ghjg.china-gis.com/server/rest/services/Hosted/黄浦江沿岸精模/SceneServer',
+    kymtLayer: 'https://ghjg.china-gis.com/server/rest/services/Hosted/客运码头/SceneServer',
+    wxpmtLayer: 'https://ghjg.china-gis.com/server/rest/services/Hosted/危险品码头/SceneServer',
+    yjyjLayer202301: 'https://ghjg.china-gis.com/server/rest/services/Hosted/第一期2023淤积/SceneServer',
+    LjzSjBefore2022: 'https://ghjg.china-gis.com/server/rest/services/Hosted/疏浚前拉伸10倍/SceneServer',
+    LjzSjAfter2022: 'https://ghjg.china-gis.com/server/rest/services/Hosted/疏浚后拉伸10倍/SceneServer',
+    dm2020H2Layer:'https://ghjg.china-gis.com/server/rest/services/Hosted/断面_2020H2/SceneServer',
+
+}

+ 94 - 90
src/utils/map/Layer.js

@@ -2,9 +2,10 @@
  * 图层加载工具类
  */
 import {setBoat} from '@/utils/map/Boat'
-import {addGraphic, addLayer, setOpacity} from "@/utils/map/ArcgisUtil";
+import {addGraphic, addLayer, clearMap, setOpacity} from "@/utils/map/ArcgisUtil";
 import {setCenter,setSxdxCamera} from '@/utils/map/Common'
 import {GetHpjDepthPoints} from '@/apis/hdsj'
+import layerConfig from '@/config/layerConfig'
 
 // let layerList = ['cb','mt','jjq','dtq','md','sszh','hb','hd','sxdx','2023.1','2022.1','2022.2','2021.1','2021.2','2020.1','2020.2']
 let layerList = []
@@ -15,7 +16,7 @@ let defaultLayerList = [
         id: 'waterPassenger',
         title: 'waterPassenger',
         type: 'feature',
-        url:'http://10.83.68.109:6080/arcgis/rest/services/water_passenger_3857/MapServer',
+        url: layerConfig.waterPassengerLayer,
         visible: false,
         opacity: 1,
         token: '',
@@ -26,7 +27,7 @@ let defaultLayerList = [
         id: 'digitalTwain',
         title: 'digitalTwain',
         type: 'feature',
-        url:'http://10.83.68.109:6080/arcgis/rest/services/digitalTwain_3857/MapServer',
+        url: layerConfig.digitalTwinLayer,
         visible: false,
         opacity: 1,
         token: '',
@@ -37,7 +38,7 @@ let defaultLayerList = [
         id: 'ghjgCxall',
         title: 'ghjgCxall',
         type: 'shc_map',
-        url:'http://10.83.68.109:6080/arcgis/rest/services/ghjg_cxall/MapServer',
+        url:layerConfig.ghjgCxAllLayer,
         visible: false,
         opacity: 1,
         token: '',
@@ -68,60 +69,6 @@ export function closeAllLayer() {
 }
 
 export function addLayerByName(name,isShow,opacity){
-    switch (name) {
-        case 'pm_2020.2':
-            GetHpjDepthPoints().then(res=>{
-                if(res.code == '200'){
-                    if(res.data.Rows != null && res.data.Rows.length > 0){
-                        let rows = res.data.Rows
-                        let dataList = []
-                        for(let i=0;i<rows.length;i++){
-                            let linePoints = rows[i]
-                            if(linePoints.length > 0){
-                                for(let j=0;j<linePoints.length;j++){
-                                    if(linePoints[j].depth == null){
-                                        continue
-                                    }
-                                    let point = {
-                                        x: linePoints[j].pointX,
-                                        y: linePoints[j].pointY,
-                                        z: linePoints[j].pointZ,
-                                        name: linePoints[j].depth
-                                    }
-                                    dataList.push(point)
-                                }
-                            }
-                        }
-                        addGraphic({
-                            "type": 'points',
-                            "is_edit": false,
-                            "is_clear": true,
-                            "is_temp": false,
-                            "is_goto": false,
-                            "data": dataList,
-                            "attributes": null,
-                            "symbol": null,
-                            "title": null
-                        })
-                    }else{
-                        this.$message({
-                            type: 'error',
-                            message: '未查询到水深点数据!'
-                        })
-                    }
-                }else{
-                    this.$message({
-                        type: 'error',
-                        message: '查询水深点数据失败!'
-                    })
-                    console.log(res.msg)
-                }
-            })
-    }
-    this.addLayers(name,isShow,opacity)
-}
-
-export function addLayers(name,isShow,opacity){
     // 存储到打开图层列表
     if(isShow){
         let isExist = false
@@ -153,7 +100,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'portLayer',
                 title: 'portLayer',
                 type: 'feature',
-                url: 'http://10.83.68.109:6080/arcgis/rest/services/digitalTwain_3857/MapServer/0',
+                url: layerConfig.digitalTwinLayer+'/0',
                 visible: isShow,
                 opacity: opacity?opacity:1,
                 token: '',
@@ -166,7 +113,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'jjqIconLayer',
                 title: 'jjqIconLayer',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/警戒区图标/SceneServer',
+                url: layerConfig.jjqIconLayer,
                 visible: isShow,
                 opacity: opacity?opacity:1,
                 token: '',
@@ -176,7 +123,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'jjqAreaLayer',
                 title: 'jjqAreaLayer',
                 type: 'feature',
-                url: 'http://10.83.68.109:6080/arcgis/rest/services/jingjiequ/MapServer',
+                url: layerConfig.jjqLayer,
                 visible: isShow,
                 opacity: opacity?opacity:0.5,
                 token: '',
@@ -190,7 +137,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'dtqIconLayer',
                 title: 'dtqIconLayer',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/掉头区图标/SceneServer',
+                url: layerConfig.dtqIconLayer,
                 visible: isShow,
                 opacity: opacity?opacity:1,
                 token: '',
@@ -200,7 +147,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'dtqAreaLayer',
                 title: 'dtqAreaLayer',
                 type: 'feature',
-                url: 'http://10.83.68.109:6080/arcgis/rest/services/backArea/MapServer',
+                url: layerConfig.dtqLayer,
                 visible: isShow,
                 opacity: opacity?opacity:0.5,
                 token: '',
@@ -213,7 +160,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'mdIconLayer',
                 title: 'mdIconLayer',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/锚地图标/SceneServer',
+                url: layerConfig.mdIconLayer,
                 visible: isShow,
                 opacity: opacity?opacity:1,
                 token: '',
@@ -223,7 +170,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'mdAreaLayer',
                 title: 'mdAreaLayer',
                 type: 'feature',
-                url: 'http://10.83.68.109:6080/arcgis/rest/services/maodi/MapServer',
+                url: layerConfig.mdLayer,
                 visible: isShow,
                 opacity: opacity?opacity:0.5,
                 token: '',
@@ -236,7 +183,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'ssfwqIconLayer',
                 title: 'ssfwqIconLayer',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/水上绿色综合服务区图标/SceneServer',
+                url: layerConfig.sszhIconLayer,
                 visible: isShow,
                 opacity: opacity?opacity:1,
                 token: '',
@@ -246,7 +193,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'ssfwqAreaLayer',
                 title: 'ssfwqAreaLayer',
                 type: 'feature',
-                url: 'http://10.83.68.109:6080/arcgis/rest/services/shuishangfuququ/MapServer',
+                url: layerConfig.sszhLayer,
                 visible: isShow,
                 opacity: opacity?opacity:0.5,
                 token: '',
@@ -259,7 +206,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'hbSceneLayer',
                 title: 'hbSceneLayer',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/航标/SceneServer',
+                url: layerConfig.hbLayer,
                 visible: isShow,
                 opacity: opacity?opacity:1,
                 token: '',
@@ -272,7 +219,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'channelLayer',
                 title: 'channelLayer',
                 type: 'feature',
-                url: 'http://10.83.68.109:6080/arcgis/rest/services/digitalTwain_3857/MapServer/2',
+                url: layerConfig.digitalTwinLayer+'/2',
                 visible: isShow,
                 opacity: opacity?opacity:1,
                 token: '',
@@ -285,7 +232,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'dbsLayer',
                 title: 'dbsLayer',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/多波束/SceneServer',
+                url: layerConfig.sxdxLayer202301,
                 visible: isShow,
                 opacity: opacity?opacity:1,
                 token: '',
@@ -304,7 +251,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'deepthLayer202301',
                 title: 'deepthLayer202301',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/多波束/SceneServer',
+                url: layerConfig.sxdxLayer202301,
                 visible: isShow,
                 opacity: opacity?opacity:1,
                 token: '',
@@ -316,7 +263,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'deepthLayer202201',
                 title: 'deepthLayer202201',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/第一期2022/SceneServer',
+                url: layerConfig.sxdxLayer202201,
                 visible: isShow,
                 opacity: opacity?opacity:1,
                 token: '',
@@ -328,7 +275,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'deepthLayer202202',
                 title: 'deepthLayer202202',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/第二期2022/SceneServer',
+                url: layerConfig.sxdxLayer202202,
                 visible: isShow,
                 opacity: 1,
                 token: '',
@@ -340,7 +287,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'deepthLayer202101',
                 title: 'deepthLayer202101',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/第一期2021/SceneServer',
+                url: layerConfig.sxdxLayer202101,
                 visible: isShow,
                 opacity: 1,
                 token: '',
@@ -352,7 +299,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'deepthLayer202102',
                 title: 'deepthLayer202102',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/第二期2021/SceneServer',
+                url: layerConfig.sxdxLayer202202,
                 visible: isShow,
                 opacity: 1,
                 token: '',
@@ -364,7 +311,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'deepthLayer202001',
                 title: 'deepthLayer202001',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/第一期2020/SceneServer',
+                url: layerConfig.sxdxLayer202001,
                 visible: isShow,
                 opacity: 1,
                 token: '',
@@ -376,7 +323,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'deepthLayer202002',
                 title: 'deepthLayer202002',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/第二期2020/SceneServer',
+                url: layerConfig.sxdxLayer202002,
                 visible: isShow,
                 opacity: 1,
                 token: '',
@@ -389,7 +336,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'hpj500mBuildingLayer',
                 title: 'hpj500mBuildingLayer',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/黄浦江周边建筑500m/SceneServer',
+                url: layerConfig.labmhPJ500Layer,
                 visible: isShow,
                 opacity: 1,
                 token: '',
@@ -399,7 +346,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'pxBuildingLayer',
                 title: 'pxBuildingLayer',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/浦西核心段白膜/SceneServer',
+                url: layerConfig.labmPxLayer,
                 visible: isShow,
                 opacity: 1,
                 token: '',
@@ -412,7 +359,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'jmBuildingLayer',
                 title: 'jmBuildingLayer',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/黄浦江沿岸精模/SceneServer',
+                url: layerConfig.lajmLayer,
                 visible: isShow,
                 opacity: 1,
                 token: '',
@@ -425,7 +372,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'kymtLayer',
                 title: 'kymtLayer',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/客运码头/SceneServer',
+                url: layerConfig.kymtLayer,
                 visible: isShow,
                 opacity: 1,
                 token: '',
@@ -438,7 +385,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'yjyjLayer',
                 title: 'yjyjLayer',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/第一期2023淤积/SceneServer',
+                url: layerConfig.yjyjLayer202301,
                 visible: isShow,
                 opacity: opacity?opacity:1,
                 token: '',
@@ -449,7 +396,7 @@ export function addLayers(name,isShow,opacity){
                     id: 'dbsLayer',
                     title: 'dbsLayer',
                     type: 'scene',
-                    url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/多波束/SceneServer',
+                    url: layerConfig.sxdxLayer202301,
                     visible: false,
                     opacity: 1,
                     token: '',
@@ -459,7 +406,7 @@ export function addLayers(name,isShow,opacity){
                     id: 'dbsLayer',
                     title: 'dbsLayer',
                     type: 'scene',
-                    url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/多波束/SceneServer',
+                    url: layerConfig.sxdxLayer202301,
                     visible: true,
                     opacity: 0.4,
                     token: '',
@@ -470,7 +417,7 @@ export function addLayers(name,isShow,opacity){
                     id: 'dbsLayer',
                     title: 'dbsLayer',
                     type: 'scene',
-                    url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/多波束/SceneServer',
+                    url: layerConfig.sxdxLayer202301,
                     visible: false,
                     opacity: 1,
                     token: '',
@@ -480,7 +427,7 @@ export function addLayers(name,isShow,opacity){
                     id: 'dbsLayer',
                     title: 'dbsLayer',
                     type: 'scene',
-                    url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/多波束/SceneServer',
+                    url: layerConfig.sxdxLayer202301,
                     visible: true,
                     opacity: 1,
                     token: '',
@@ -494,7 +441,7 @@ export function addLayers(name,isShow,opacity){
                 id: '2022LjzBefore',
                 title: '2022LjzBefore',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/疏浚前拉伸10倍/SceneServer',
+                url: layerConfig.LjzSjBefore2022,
                 visible: isShow,
                 opacity: 1,
                 token: '',
@@ -507,7 +454,7 @@ export function addLayers(name,isShow,opacity){
                 id: '2022LjzAfterLayer',
                 title: '2022LjzAfterLayer',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/疏浚后拉伸10倍/SceneServer',
+                url: layerConfig.LjzSjAfter2022,
                 visible: isShow,
                 opacity: 1,
                 token: '',
@@ -520,7 +467,7 @@ export function addLayers(name,isShow,opacity){
                 id: 'dangerPortLayer',
                 title: 'dangerPortLayer',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/危险品码头/SceneServer',
+                url: layerConfig.wxpmtLayer,
                 visible: isShow,
                 opacity: opacity?opacity:1,
                 token: '',
@@ -536,11 +483,68 @@ export function addLayers(name,isShow,opacity){
                 id: 'warterDepthLineLayer',
                 title: 'warterDepthLineLayer',
                 type: 'scene',
-                url: 'https://geoscene.geosceneonline.cn/server/rest/services/Hosted/断面_2020H2/SceneServer',
+                url: layerConfig.dm2020H2Layer,
                 visible: isShow,
                 opacity: opacity?opacity:1,
                 token: ''
             })
+
+            if(isShow){
+                GetHpjDepthPoints().then(res=>{
+                    if(res.code == '200'){
+                        if(res.data.Rows != null && res.data.Rows.length > 0){
+                            let rows = res.data.Rows
+                            let dataList = []
+                            for(let i=0;i<rows.length;i++){
+                                let linePoints = rows[i]
+                                if(linePoints.length > 0){
+                                    for(let j=0;j<linePoints.length;j++){
+                                        if(linePoints[j].depth == null){
+                                            continue
+                                        }
+                                        let point = {
+                                            x: linePoints[j].pointX,
+                                            y: linePoints[j].pointY,
+                                            z: linePoints[j].pointZ * 10,
+                                            text: linePoints[j].depth
+                                        }
+                                        dataList.push(point)
+                                    }
+                                }
+                            }
+                            addGraphic({
+                                "type": 'points',
+                                "is_edit": false,
+                                "is_clear": true,
+                                "is_temp": false,
+                                "is_goto": false,
+                                "data": dataList,
+                                "attributes": null,
+                                "symbol": {
+                                    type: "simple-marker",
+                                    style: "circle",
+                                    color: [255, 255, 255],
+                                    size: 5
+                                },
+                                "title": null
+                            })
+                        }else{
+                            this.$message({
+                                type: 'error',
+                                message: '未查询到水深点数据!'
+                            })
+                        }
+                    }else{
+                        this.$message({
+                            type: 'error',
+                            message: '查询水深点数据失败!'
+                        })
+                        console.log(res.msg)
+                    }
+                })
+            }else{
+                clearMap({is_draw: true, is_search:true, layers: []})
+            }
             break
     }
 }