From 02d584c8d0f31b56f24e367681aa034cd2acf0e9 Mon Sep 17 00:00:00 2001 From: wangrui <zephyrs0894@163.com> Date: 星期六, 19 十二月 2020 02:20:38 +0800 Subject: [PATCH] 重构地图加载的逻辑 --- src/conf/MapConfig.js | 183 +++++++++++++++++++++++++++++++++++---------- 1 files changed, 140 insertions(+), 43 deletions(-) diff --git a/src/conf/MapConfig.js b/src/conf/MapConfig.js index f1f4cb6..b41eec9 100644 --- a/src/conf/MapConfig.js +++ b/src/conf/MapConfig.js @@ -4,19 +4,12 @@ let pathname = window.document.location.pathname let pos = curWwwPath.indexOf(pathname) let HOST_URL = curWwwPath.substring(0, pos) -// const sconfig = { -// // 'ip' : '10.246.151.116', -// // 'port' : '8093', -// 'ip': '10.238.221.80', -// 'port': '8088', -// 'ifS': 'http', -// 'name': '/hcss' -// } -// const DMHttpService1 = sconfig.ifS + '://' + sconfig.ip + ':' + sconfig.port + sconfig.name + '/' -const GIS_URL = 'http://10.238.221.80:6080' -const BLUEMAP_HOST = 'http://xearth.cn:6288/' +const BLUEMAP_HOST = 'http://xearth.cn:6288/' // 鍏徃鍙戝竷鐨勫湴鍥炬湇鍔★紝鐢ㄤ簬娴嬭瘯鐨勫湴鍧� +const SINOPEC_GIS_HOST = 'http://10.246.132.249:8080' // 鍐呯綉澶╁湴鍥句富鏈哄湴鍧� +const TIANDITU_GIS_HOST = 'http://t0.tianditu.gov.cn' // 鍏綉澶╁湴鍥句富鏈哄湴鍧� +const TIANDITU_GIS_TOKEN = '5d76218063082952d18b76da5005f490' // 澶囩敤tk: f1b72b5e7cb1175acddfa485f1bc9770 const mapOptions = { crs: L.CRS.EPSG4326, minZoom: 3, @@ -31,38 +24,140 @@ const mapConfig = { IsLoadMapByToken: true, // 鏄惁閫氳繃token鍔犺浇鍦板浘 showBaseMapType: 1, // 1鏄剧ず澶╁湴鍥撅紝2鏄剧ずarcgis鍦板浘 - TDTBaseMaps: [ + IntranetBaseMaps: [ { - layerName: '澶╁湴鍥惧奖鍍忓湴鍥�', - type: 'wmts', - visible: false, - layerType: 'img_c', - isLoadMapByToken: true, - url: 'http://10.246.132.249:8080/OneMapServer/rest/services/base-tdt-image-globe/WMTS' + code: 'sinopec_img', + name: '涓煶鍖栧ぉ鍦板浘褰卞儚', + isAddToMap: true, + map: { + layerName: '澶╁湴鍥惧奖鍍忓湴鍥�', + type: 'wmts', + visible: false, + layerType: 'img_c', + isLoadMapByToken: true, + url: SINOPEC_GIS_HOST + '/OneMapServer/rest/services/base-tdt-image-globe/WMTS', + option:{ + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 + } + }, + annotation: { + layerName: '澶╁湴鍥惧奖鍍忔爣娉�', + type: 'wmts', + visible: false, + layerType: 'cia_c', + isLoadMapByToken: true, + url: SINOPEC_GIS_HOST + '/OneMapServer/rest/services/base-tdt-label-image/WMTS', + option:{ + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 + } + }, }, { - layerName: '澶╁湴鍥惧奖鍍忔爣娉�', - type: 'wmts', - visible: false, - layerType: 'cia_c', - isLoadMapByToken: true, - url: 'http://10.246.132.249:8080/OneMapServer/rest/services/base-tdt-label-image/WMTS' + code: 'sinopec_vec', + name: '涓煶鍖栧ぉ鍦板浘鐭㈤噺', + isAddToMap: false, + map: { + layerName: '澶╁湴鍥剧煝閲忓湴鍥�', + type: 'wmts', + visible: false, + layerType: 'vec_c', + isLoadMapByToken: true, + url: SINOPEC_GIS_HOST + '/OneMapServer/rest/services/base-tdt-vector-globe/WMTS', + option:{ + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 + } + }, + annotation: { + layerName: '澶╁湴鍥剧煝閲忔爣娉�', + type: 'wmts', + visible: false, + layerType: 'cva_c', + isLoadMapByToken: true, + url: SINOPEC_GIS_HOST + '/OneMapServer/rest/services/base-tdt-label-vector/WMTS', + option:{ + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 + } + } + } + ], + InternetBaseMaps: [ + { + code: 'tianditu_img', + name: '澶╁湴鍥惧奖鍍�', + isAddToMap: true, + map: { + layerName: '澶╁湴鍥惧奖鍍忓湴鍥�', + type: 'wmts', + visible: false, + layerType: 'img_c', + isLoadMapByToken: true, + url: TIANDITU_GIS_HOST + '/img_c/wmts?layer=img&style=default&tilematrixset=c'+ + '&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}'+ + '&tk=' + TIANDITU_GIS_TOKEN, + option:{ + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 + } + }, + annotation: { + layerName: '澶╁湴鍥惧奖鍍忔爣娉�', + type: 'wmts', + visible: false, + layerType: 'cia_c', + isLoadMapByToken: true, + url: TIANDITU_GIS_HOST + '/cia_c/wmts?layer=cia&style=default&tilematrixset=c'+ + '&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}'+ + '&tk=' + TIANDITU_GIS_TOKEN, + option:{ + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 + } + }, }, { - layerName: '澶╁湴鍥剧煝閲忓湴鍥�', - type: 'wmts', - visible: false, - layerType: 'vec_c', - isLoadMapByToken: true, - url: 'http://10.246.132.249:8080/OneMapServer/rest/services/base-tdt-vector-globe/WMTS' - }, - { - layerName: '澶╁湴鍥剧煝閲忔爣娉�', - type: 'wmts', - visible: false, - layerType: 'cva_c', - isLoadMapByToken: true, - url: 'http://10.246.132.249:8080/OneMapServer/rest/services/base-tdt-label-vector/WMTS' + code: 'tianditu_vec', + name: '澶╁湴鍥惧奖鍍�', + isAddToMap: false, + map: { + layerName: '澶╁湴鍥剧煝閲忓湴鍥�', + type: 'wmts', + visible: false, + layerType: 'vec_c', + isLoadMapByToken: true, + url: TIANDITU_GIS_HOST + '/vec_c/wmts?layer=vec&style=default&tilematrixset=c'+ + '&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}'+ + '&tk=' + TIANDITU_GIS_TOKEN, + option:{ + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 + } + }, + annotation: { + layerName: '澶╁湴鍥剧煝閲忔爣娉�', + type: 'wmts', + visible: false, + layerType: 'cva_c', + isLoadMapByToken: true, + url: TIANDITU_GIS_HOST + '/cva_c/wmts?layer=cva&style=default&tilematrixset=c'+ + '&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}'+ + '&tk=' + TIANDITU_GIS_TOKEN, + option:{ + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 + } + } } ], ArcBaseMaps: [ @@ -72,14 +167,16 @@ visible: true, layerType: 'cia_c', isLoadMapByToken: false, - url: 'http://10.246.132.249:8080/OneMapServer/rest/services/base-map-image-globe/MapServer' - }], - GeometryServer: GIS_URL + '/arcgis/rest/services/Utilities/Geometry/GeometryServer', - FenceUrl: GIS_URL + '/arcgis/rest/services/fence', + url: SINOPEC_GIS_HOST + '/OneMapServer/rest/services/base-map-image-globe/MapServer' + } + ] } +/** + * 鍐呯綉GIS锛岃幏鍙杢oken鍙傛暟 + */ const TokenConfig = { - url: 'http://10.246.132.249:8080/RemoteTokenServer', // 鑾峰彇token鐨勬湇鍔℃帴鍙� + url: SINOPEC_GIS_HOST + '/RemoteTokenServer', // 鑾峰彇token鐨勬湇鍔℃帴鍙� option: { request: 'getToken', username: 'sipms', // 鑾峰彇token鐨勭敤鎴峰悕 -- Gitblit v1.8.0