From 1883c95da4b79da03365e8e0eea6b917e6cb4f10 Mon Sep 17 00:00:00 2001 From: 徐旺旺 <11530253@qq.com> Date: 星期五, 26 二月 2021 12:11:01 +0800 Subject: [PATCH] 修改图层控制 --- public/assets/images/map/sewers/管线点.png | 0 package.json | 1 src/conf/LayerSewers.js | 103 ++++++++++++++-------------------- src/components/helpers/ServiceLayerHelper.js | 29 ++++----- 4 files changed, 58 insertions(+), 75 deletions(-) diff --git a/package.json b/package.json index ba42def..e098be7 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "leaflet.markercluster": "^1.4.1", "lodash": "^4.17.10", "nprogress": "^0.2.0", + "rbush": "^3.0.1", "screenfull": "^3.3.2", "vue": "^2.6.11", "vue-count-to": "^1.0.13", diff --git "a/public/assets/images/map/sewers/\347\256\241\347\272\277\347\202\271.png" "b/public/assets/images/map/sewers/\347\256\241\347\272\277\347\202\271.png" new file mode 100644 index 0000000..f20b5cf --- /dev/null +++ "b/public/assets/images/map/sewers/\347\256\241\347\272\277\347\202\271.png" Binary files differ diff --git a/src/components/helpers/ServiceLayerHelper.js b/src/components/helpers/ServiceLayerHelper.js index eb4eb9e..fa100b0 100644 --- a/src/components/helpers/ServiceLayerHelper.js +++ b/src/components/helpers/ServiceLayerHelper.js @@ -5,6 +5,7 @@ import AjaxUtils from '@/utils/AjaxUtils' import store from '@/store' +var myRenderer = window.L.canvas() class ServiceLayerHelper { constructor (options) { this.map = options.map @@ -69,16 +70,16 @@ } } - loadGeojsonLayer (url, layer) { + loadGeojsonLayer (url, item) { var matches = this.regex.exec(url) - var matchValue = layer[matches[1]] - var code = layer.code + var matchValue = item[matches[1]] + var code = item.code var newUrl = url.replace(this.regex, matchValue) var that = this if (!that.geojsonArray[code]) { AjaxUtils.GetDataAsynByUrl(newUrl, {}, function (res) { store.commit('setSewersDatas', res) - var layer = that.loadGeojson(res) + var layer = that.loadGeojson(res, item) that.geojsonArray[code] = layer }) } @@ -88,12 +89,10 @@ * 鍔犺浇鐐规暟鎹� * @param res */ - loadGeojson (res) { + loadGeojson (res, layer) { var that = this - const featureGroup = that.L.featureGroup([], { - attribution: { id: '123' } - }).addTo(that.map) - that.L.geoJSON(res.features, { + var icon = layer.icon + return that.L.geoJSON(res.features, { style: function (feature) { return { fill: true, @@ -111,16 +110,16 @@ { radius: 20, img: { - url: 'assets/images/map/marker-icon.png', + // url: 'assets/images/map/marker-icon.png', + url: '/assets/images/map/' + icon, size: [20, 20] } }) - } + }, + renderer: myRenderer }).bindPopup(function (layer) { - // return layer.feature.properties.linenumber - }).addTo(featureGroup) - featureGroup.bringToBack() - return featureGroup + return layer.feature.properties.linenumber + }).addTo(that.map) } removeLayer (item) { diff --git a/src/conf/LayerSewers.js b/src/conf/LayerSewers.js index 02f9a31..999b68c 100644 --- a/src/conf/LayerSewers.js +++ b/src/conf/LayerSewers.js @@ -1,4 +1,3 @@ -import { GEOM_TYPE } from './Constants' // const APP_GIS_HOST_2 = 'http://xearth.cn:6230' // const APP_GIS_HOST_2 = 'http://localhost:3000' const APP_GIS_HOST_2 = 'http://192.168.31.226:8088' @@ -100,63 +99,59 @@ code: 'fsss', name: '闄勫睘璁炬柦', checked: false, // 榛樿閫変腑鐘舵�� - url: APP_GIS_HOST_2 + '/layer/findLayer?layerName={sname}', + url: APP_GIS_HOST_2 + '/server/ogcserver/PipeLine/wfs?version=1.0.0&TYPENAME={sname}&REQUEST=getfeature&OUTPUTFORMAT=json&maxFeatures=20000', filters: [ { code: 'fourlink', name: '鍥涢��', - sname: 'FourLink', + sname: '鍥涢��', checked: false, - geomtype: GEOM_TYPE.POINT + icon: 'sewers/鍥涢��.png' }, { code: 'tee', name: '涓夐��', - sname: 'Tee', + sname: '涓夐��', checked: false, - geomtype: GEOM_TYPE.POINT + icon: 'sewers/涓夐��.png' }, { code: 'piperack', name: '绠℃灦(澧�)', sname: 'PipeRack', - checked: false, - geomtype: GEOM_TYPE.POINT + checked: false }, { code: 'pipegallery', name: '绠″粖(甯�)', sname: 'PipeGallery', - checked: false, - geomtype: GEOM_TYPE.POINT + checked: false }, { code: 'pipesegment', name: '娴佸悜', sname: 'ywslx', - checked: false, - geomtype: GEOM_TYPE.POINT + checked: false }, { code: 'pipeline', name: '绠$綉', sname: 'pipeline', - checked: false, - geomtype: GEOM_TYPE.POINT + checked: false }, { code: 'valve', name: '闃�闂�', sname: 'valve', checked: false, - geomtype: GEOM_TYPE.POINT + icon: 'sewers/闃�闂�.png' }, { code: 'elbow', name: '寮ご', sname: 'Elbow', checked: false, - geomtype: GEOM_TYPE.POINT + icon: 'sewers/寮ご.png' } ] }, @@ -164,56 +159,53 @@ code: 'hbss', name: '鐜繚璁炬柦', checked: false, // 榛樿閫変腑鐘舵�� - url: APP_GIS_HOST_2 + '/layer/findLayer?layerName={sname}', + url: APP_GIS_HOST_2 + '/server/ogcserver/PipeLine/wfs?version=1.0.0&TYPENAME={sname}&REQUEST=getfeature&OUTPUTFORMAT=json&maxFeatures=20000', filters: [ { code: 'manhole', name: '绐ㄤ簳', sname: '绐ㄤ簳', checked: false, - geomtype: GEOM_TYPE.POINT + icon: 'sewers/绐ㄤ簳.png' }, { code: 'firedike', name: '闃茬伀鍫�', sname: '闃茬伀鍫�', - checked: false, - geomtype: GEOM_TYPE.POINT + checked: false }, { code: 'raingate', name: '闆ㄧ瀛�', sname: '闆ㄧ瀛�', checked: false, - geomtype: GEOM_TYPE.POINT + icon: 'sewers/闆ㄧ瀛�.png' }, { code: 'overflowweir', name: '婧㈡祦鍫�', sname: '婧㈡祦鍫�', - checked: false, - geomtype: GEOM_TYPE.POINT + checked: false }, { code: 'chokevalve', name: '鎴祦闂�', sname: '鎴祦闂�', - checked: false, - geomtype: GEOM_TYPE.POINT + checked: false }, { code: 'collectingbasin', name: '闆嗘按姹�(缃�)', sname: '闆嗘按姹�', checked: false, - geomtype: GEOM_TYPE.POINT + icon: 'sewers/闆嗘按姹�.png' }, { code: 'oilseparator', name: '闅旀补姹�', sname: '闅旀补姹�', checked: false, - geomtype: GEOM_TYPE.POINT + icon: 'sewers/闅旀补姹�.png' } ] }, @@ -221,14 +213,13 @@ code: 'pk', name: '鎺掑彛', checked: false, // 榛樿閫変腑鐘舵�� - url: APP_GIS_HOST_2 + '/layer/findLayer?layerName={sname}', + url: APP_GIS_HOST_2 + '/server/ogcserver/PipeLine/wfs?version=1.0.0&TYPENAME={sname}&REQUEST=getfeature&OUTPUTFORMAT=json&maxFeatures=20000', filters: [ { code: 'dischargeport', name: '鎺掓斁鍙�', sname: '鎺掓斁鍙�', - checked: false, - geomtype: GEOM_TYPE.POINT + checked: false } ] }, @@ -236,154 +227,146 @@ code: 'qyxx', name: '鍖哄煙淇℃伅', checked: false, // 榛樿閫変腑鐘舵�� - url: APP_GIS_HOST_2 + '/layer/findLayer?layerName={sname}', + url: APP_GIS_HOST_2 + '/server/ogcserver/PipeLine/wfs?version=1.0.0&TYPENAME={sname}&REQUEST=getfeature&OUTPUTFORMAT=json&maxFeatures=20000', filters: [ { code: 'thirdpartypipe', name: '绗笁鏂圭閬�', sname: '绗笁鏂圭閬�', - checked: false, - geomtype: GEOM_TYPE.POINT + checked: false }, { code: 'firefightingunit', name: '娑堥槻鍗曚綅', sname: '娑堥槻鍗曚綅', checked: false, - geomtype: GEOM_TYPE.POINT + icon: 'sewers/娑堥槻鍗曚綅.png' }, { code: 'emergencyesources', name: '搴旀�ョ墿璧�', sname: '搴旀�ョ墿璧�', - checked: false, - geomtype: GEOM_TYPE.POINT + checked: false }, { code: 'emergencyres', name: '绀句細涓撲笟搴旀�ユ晳鎻撮槦浼�', sname: '涓撲笟搴旀�ユ晳鎻�', checked: false, - geomtype: GEOM_TYPE.POINT + icon: 'sewers/绀句細涓撲笟搴旀�ユ晳鎻�.png' }, { code: 'maintenanceteam', name: '缁存姠淇槦浼�', sname: '缁存姠淇槦浼�', checked: false, - geomtype: GEOM_TYPE.POINT + icon: 'sewers/绀句細涓撲笟搴旀�ユ晳鎻�.png' }, { code: 'hospital', name: '鍖婚櫌', sname: '鍖婚櫌', checked: false, - geomtype: GEOM_TYPE.POINT + icon: 'sewers/鍖婚櫌.png' }, { code: 'pointpreservationzone', name: '鑷劧淇濇姢鍖�', sname: '鑷劧淇濇姢鍖�', checked: false, - geomtype: GEOM_TYPE.POINT + icon: 'sewers/鑷劧淇濇姢鍖�.png' }, { code: 'pointhydrology', name: '姘翠綋', sname: '姘翠綋', checked: false, - geomtype: GEOM_TYPE.POINT + icon: 'sewers/姘翠綋.png' }, { code: 'sensitivetarget', name: '鏁忔劅鐩爣', sname: '鏁忔劅鐩爣', checked: false, - geomtype: GEOM_TYPE.POINT + icon: 'sewers/鏁忔劅鐩爣.png' }, { code: 'envmonunit', name: '鐜鐩戞祴鍗曚綅', sname: '鐜鐩戞祴鍗曚綅', checked: false, - geomtype: GEOM_TYPE.POINT + icon: 'sewers/鐜鐩戞祴鍗曚綅.png' }, { code: 'pointcontaminants', name: '鐩戞祴鐐规薄鏌撶墿鎸囨爣淇℃伅', sname: '姹℃煋鐗╂寚鏍�', - checked: false, - geomtype: GEOM_TYPE.POINT + checked: false }, { code: 'dischargeportaround', name: '鎺掓斁鍙e懆杈圭幆澧冩晱鎰熶俊鎭�', sname: '鎺掓斁鍙e懆杈圭幆澧�', checked: false, - geomtype: GEOM_TYPE.POINT + iconN: 'sewers/鎺掓斁鍙e懆杈规晱鎰熶俊鎭�.png' }, { code: 'pump', name: '娉�', sname: '娉�', checked: false, - geomtype: GEOM_TYPE.POINT + icon: 'sewers/娉�.png' }, { code: 'liquidlevelmeter', name: '娑蹭綅璁�', sname: '娑蹭綅璁�', checked: false, - geomtype: GEOM_TYPE.POINT + icon: 'sewers/娑蹭綅璁�.png' }, { code: 'flowmeter', name: '娴侀噺璁�', sname: '娴侀噺璁�', checked: false, - geomtype: GEOM_TYPE.POINT + icon: 'sewers/娴侀噺璁�.png' }, { code: 'video', name: '瑙嗛鐩戞帶閰嶇疆', sname: '瑙嗛鐩戞帶', - checked: false, - geomtype: GEOM_TYPE.POINT + checked: false }, { code: 'onlinemonitoring', name: '鍦ㄧ嚎鐩戞祴璁惧閰嶇疆', sname: '鍦ㄧ嚎鐩戞祴', - checked: false, - geomtype: GEOM_TYPE.POINT + checked: false }, { code: 'combustiblegas', name: '鍙噧姘斾綋鎶ヨ璁惧閰嶇疆', sname: '鍙噧姘斾綋鎶ヨ', - checked: false, - geomtype: GEOM_TYPE.POINT + checked: false }, { code: 'hydrogensulfide', name: 'H2S娴撳害鎶ヨ璁惧閰嶇疆', sname: 'H2S娴撳害鎶ヨ', - checked: false, - geomtype: GEOM_TYPE.POINT + checked: false }, { code: 'controlpoint', name: '绠$嚎鐐�', sname: '绠$嚎鐐�', checked: false, - geomtype: GEOM_TYPE.POINT + icon: 'sewers/绠$嚎鐐�.png' }, { code: 'pipesegment', name: '绠℃', sname: '绠℃', - checked: false, - geomtype: GEOM_TYPE.POINT + checked: false } ] } -- Gitblit v1.8.0