From 77e1bf3098cbf4bc19dafd76995f6e13ee9361f7 Mon Sep 17 00:00:00 2001
From: chenzeping <ChenZeping02609@163.com>
Date: 星期一, 19 四月 2021 14:05:19 +0800
Subject: [PATCH] Merge branch 'develop' of http://xearth.cn:6600/r/wuyushui/SewerAndRainNetwork into develop
---
src/conf/layers/LayerPipeLines.js | 6 +-
src/components/LayerController/logic/PipeLineAnimal.js | 42 +++++----------------
src/components/LayerController/service/LayerFactory.js | 30 +++++++++++++--
src/components/panel/topicSearch/SewersSearch.vue | 4 -
src/utils/utils.js | 35 +++++++++++++++++
5 files changed, 75 insertions(+), 42 deletions(-)
diff --git a/src/components/LayerController/logic/PipeLineAnimal.js b/src/components/LayerController/logic/PipeLineAnimal.js
index f712d96..e9cabbe 100644
--- a/src/components/LayerController/logic/PipeLineAnimal.js
+++ b/src/components/LayerController/logic/PipeLineAnimal.js
@@ -11,20 +11,22 @@
for (var i = 0; i < layers.length; i++) {
const config = layers[i]
const code = config.code
+ const styles = config.styles
// window.layerFactory.show(config)
const layer = window.layerFactory.layers[code]
if (layer) {
if (layer.eachLayer) {
layer.eachLayer(function (layer) {
+ var newStyles = Object.assign(STYLES, styles)
layer.setStyle({
- fill: STYLES.FILL,
- weight: STYLES.WEIGHT,
- fillColor: STYLES.FILL_COLOR,
- color: STYLES.COLOR,
- fillOpacity: STYLES.FILL_OPACITY,
- opacity: STYLES.OPACITY,
- dashArray: STYLES.DASH_ARRAY,
- dashSpeed: STYLES.DASH_SPPED
+ fill: newStyles.FILL,
+ weight: newStyles.WEIGHT,
+ fillColor: newStyles.FILL_COLOR,
+ color: newStyles.COLOR,
+ fillOpacity: newStyles.FILL_OPACITY,
+ opacity: newStyles.OPACITY,
+ dashArray: newStyles.DASH_ARRAY,
+ dashSpeed: newStyles.DASH_SPPED
})
})
// 閲嶆柊娣诲姞鍒板湴鍥句笂锛屽姩鐢绘墠鏈夋晥鏋�
@@ -33,33 +35,9 @@
}
}
}
- /* window.$layer.iframe({
- content: {
- content: publicBounced,
- parent: this,
- data: {
- info: this.info,
- fn: () => {
- alert(1)
- }
- }
- },
- area: ['901px', '101px'],
- title: '杩欐槸涓�涓爣棰樿繖鏄竴涓爣棰樿繖鏄竴涓爣棰樿繖鏄竴涓爣棰�',
- maxmin: true,
- shade: false,
- shadeClose: false,
- scrollbar: false,
- resize: true,
- btn: ['a', 'b'],
- cancel: () => {
- alert(2110)
- }
- }) */
}
this.destory = () => {
- console.log('destory!!!')
const layers = LayerPipeLines.layers
for (var i = 0; i < layers.length; i++) {
const config = layers[i]
diff --git a/src/components/LayerController/service/LayerFactory.js b/src/components/LayerController/service/LayerFactory.js
index d475fb6..9b05042 100644
--- a/src/components/LayerController/service/LayerFactory.js
+++ b/src/components/LayerController/service/LayerFactory.js
@@ -2,7 +2,7 @@
import BusiLayerService from './BusiLayerService'
import WmsLayerService from './WmsLayerService'
import EventLayerService from './EventLayerService'
-
+import { clone } from '../../../utils/utils'
class LayerFactory {
constructor (options) {
this.L = options.L
@@ -112,15 +112,37 @@
hide (config) {
var layer = this.layers[config.code]
layer && this.map.removeLayer(layer)
- this.load(config)
+ // this.load(config)
}
toggle (code) {
}
- flyByLayerId (code, id) {
- const layer = this.layers[code]
+ /**
+ *
+ * 鏍规嵁浼犵殑 feature瀵硅薄瀹氫綅
+ * @param code
+ * @param feature
+ */
+ flyByFeature (feature, code) {
+ const type = feature.geometry.type
+ var point = []
+ switch (type) {
+ case 'Point':
+ point = clone(feature.geometry.coordinates)
+ break
+ case 'MultiLineString':
+ var coordinates = feature.geometry.coordinates
+ point = clone(coordinates[parseInt(coordinates.length / 2)][0])
+ break
+ }
+ window.map.flyTo(point.reverse(), 15)
+ code && this.openPopup(code, feature.id)
+ }
+
+ openPopup (layerId, id) {
+ const layer = this.layers[layerId]
if (layer.eachLayer) {
layer.eachLayer(function (layer) {
diff --git a/src/components/panel/topicSearch/SewersSearch.vue b/src/components/panel/topicSearch/SewersSearch.vue
index 444dcdc..b30e701 100644
--- a/src/components/panel/topicSearch/SewersSearch.vue
+++ b/src/components/panel/topicSearch/SewersSearch.vue
@@ -137,9 +137,7 @@
}
},
handleLocation (val) {
- const bound = this.L.geoJSON([val], {}).getBounds()
- window.map.flyToBounds(bound)
- window.layerFactory.flyByLayerId(this.form.dataType.code, val.id)
+ window.layerFactory.flyByFeature(val, this.form.dataType.code)
// layer && layer.openPopup()
}
}
diff --git a/src/conf/layers/LayerPipeLines.js b/src/conf/layers/LayerPipeLines.js
index 4686fd6..016ba63 100644
--- a/src/conf/layers/LayerPipeLines.js
+++ b/src/conf/layers/LayerPipeLines.js
@@ -19,7 +19,7 @@
sname: '绠$綉',
checked: false,
// wfs: WFS_URL + '?TYPENAME=绠$綉&FILTER=<Filter xmlns="http://www.opengis.net/ogc"><PropertyIsEqualTo><PropertyName>mediumtype</PropertyName><Literal>闆ㄦ按绠$嚎</Literal></PropertyIsEqualTo></Filter>',
- wfs: 'http://xearth.cn:6240/geoserver/sewer/wfs?typeName=sewer:pipeline&maxFeatures=50&outputFormat=application%2Fjson&cql_filter=linenumtype=\'闆ㄦ按绠$嚎\'',
+ wfs: 'http://xearth.cn:6240/geoserver/sewer/wfs?typeName=sewer:pipeline&maxFeatures=500&outputFormat=application%2Fjson&cql_filter=linenumtype=\'闆ㄦ按绠$嚎\'',
icon: 'sewers/闆ㄦ按绾�.png',
color: '#0070ff',
minZoom: 13,
@@ -43,7 +43,7 @@
checked: false,
minZoom: 13,
color: '#ffaa00',
- wfs: 'http://xearth.cn:6240/geoserver/sewer/wfs?typeName=sewer:pipeline&maxFeatures=50&outputFormat=application%2Fjson&cql_filter=mediumtype=\'鍚补姹℃按\'',
+ wfs: 'http://xearth.cn:6240/geoserver/sewer/wfs?typeName=sewer:pipeline&maxFeatures=500&outputFormat=application%2Fjson&cql_filter=mediumtype=\'鍚补姹℃按\'',
styles: {
COLOR: '#ffaa00',
FILL_COLOR: '#ffaa00'
@@ -96,7 +96,7 @@
checked: false,
minZoom: 13,
color: '#a8a800',
- wfs: 'http://xearth.cn:6240/geoserver/sewer/wfs?typeName=sewer:pipeline&maxFeatures=50&outputFormat=application%2Fjson&cql_filter=mediumtype=\'鐢熶骇姹℃按\'',
+ wfs: 'http://xearth.cn:6240/geoserver/sewer/wfs?typeName=sewer:pipeline&maxFeatures=500&outputFormat=application%2Fjson&cql_filter=mediumtype=\'鐢熶骇姹℃按\'',
styles: {
COLOR: '#a8a800',
FILL_COLOR: '#a8a800'
diff --git a/src/utils/utils.js b/src/utils/utils.js
index 8ace9bb..4fbfed4 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -22,3 +22,38 @@
// eslint-disable-next-line no-unreachable
return url + '\n' + arg + '\n' + argValue
}
+
+/**
+ * 澶嶅埗瀵硅薄
+ * @param obj
+ * @returns {{}}
+ */
+export function clone (obj) {
+ var o
+ // 濡傛灉 浠栨槸瀵硅薄object鐨勮瘽 , 鍥犱负null,object,array 涔熸槸'object';
+ if (typeof obj === 'object') {
+ // 濡傛灉 浠栨槸绌虹殑璇�
+ if (obj === null) {
+ o = null
+ } else {
+ // 濡傛灉 浠栨槸鏁扮粍arr鐨勮瘽
+ if (obj instanceof Array) {
+ o = []
+ for (var i = 0, len = obj.length; i < len; i++) {
+ o.push(clone(obj[i]))
+ }
+ } else {
+ // 濡傛灉 浠栨槸瀵硅薄object鐨勮瘽
+ o = {}
+ for (var j in obj) {
+ o[j] = clone(obj[j])
+ }
+ }
+ }
+ } else {
+ o = obj
+ }
+ return o
+}
+
+export default clone
--
Gitblit v1.8.0