From c56e506fd34c58209240e97fc29043639fae5d19 Mon Sep 17 00:00:00 2001 From: ChenZeping <chenzeping> Date: 星期四, 29 四月 2021 15:13:21 +0800 Subject: [PATCH] 统计表,指标,预报警表格弹框公共修改,管线分析功能 --- src/components/LayerController/service/WfsLayerService.js | 100 ++++++++++++++++++++++++++++--------------------- 1 files changed, 57 insertions(+), 43 deletions(-) diff --git a/src/components/LayerController/service/WfsLayerService.js b/src/components/LayerController/service/WfsLayerService.js index e1bd4a5..c280a83 100644 --- a/src/components/LayerController/service/WfsLayerService.js +++ b/src/components/LayerController/service/WfsLayerService.js @@ -3,6 +3,7 @@ */ import { STYLES } from '../../../conf/Constants' import AjaxUtils from '../../../utils/AjaxUtils' +import { setZIndex } from '../../../utils/utils' class WfsLayerService { constructor (config) { @@ -34,55 +35,64 @@ } draw (features) { - const icon = this.config.icon - const styles = this.config.styles - Object.assign(STYLES, styles) - const geojsonLayer = this.L.geoJSON(features, { - style: function (feature) { - return { - 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 - } - }, - pointToLayer: (geoJsonPoint, latlng) => { - return this.L.canvasMarker(latlng, - { - img: { - // url: 'assets/images/map/marker-icon.png', - url: '/assets/images/map/' + icon, - size: STYLES.ICON_SIZE - } + if (features && features.length > 0) { + const icon = this.config.icon + const styles = this.config.styles + Object.assign(STYLES, styles) + const geojsonLayer = this.L.geoJSON(features, { + style: function (feature) { + return { + 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 + } + }, + pointToLayer: (geoJsonPoint, latlng) => { + return this.L.canvasMarker(latlng, + { + img: { + // url: 'assets/images/map/marker-icon.png', + url: '/assets/images/map/' + icon, + size: STYLES.ICON_SIZE + } + }) + }, + onEachFeature: (feature, layer) => { + /* layer.bindPopup((layer) => { + this.popupComp.setDatas(layer) + this.popupComp.setShow() + return this.popupComp.$el + }, { + className: 's-map-popup', + minWidth: 300, + closeButton: false, + autoClose: false + }) */ + layer.bindTooltip((layer) => this.tooltipListener(layer), { + direction: 'bottom', + offset: [0, 15], + sticky: true }) - }, - onEachFeature: (feature, layer) => { - layer.bindPopup((layer) => { - this.popupComp.setDatas(layer) - this.popupComp.setShow() - return this.popupComp.$el - }, { - className: 's-map-popup', - minWidth: 300, - closeButton: false, - autoClose: false - }) - .bindTooltip((layer) => this.tooltipListener(layer), { direction: 'bottom', offset: [0, 15], sticky: true }) - .on('mouseover', (e) => this.mouseOverListener(e, layer)).on('mouseout', (e) => this.mouseOutListener(e, layer)) - } - }).addTo(this.layer) - window.layerFactory.setZIndex(geojsonLayer) + .on('mouseover', (e) => this.mouseOverListener(e, layer)).on('mouseout', (e) => this.mouseOutListener(e, layer)) + } + }).addTo(this.layer) + setZIndex(geojsonLayer) + } } mouseOverListener (e, layer) { const icon = this.config.icon const type = e.target.feature.geometry.type if (type === 'LineString' || type === 'MultiLineString') { - layer.setStyle({ weight: 8, color: '#00ffff' }) + layer.setStyle({ + weight: 8, + color: '#00ffff' + }) } else if (type === 'Point' || type === 'MultiPoint') { layer.setStyle({ img: { @@ -98,7 +108,10 @@ const icon = this.config.icon const type = e.target.feature.geometry.type if (type === 'LineString' || type === 'MultiLineString') { - layer.setStyle({ weight: STYLES.WEIGHT, color: STYLES.COLOR }) + layer.setStyle({ + weight: STYLES.WEIGHT, + color: STYLES.COLOR + }) } if (type === 'Point' || type === 'MultiPoint') { layer.setStyle({ @@ -124,4 +137,5 @@ return name } } + export default WfsLayerService -- Gitblit v1.8.0