From 7f1be6bc4e0da71ce6476232512013f2d20972cc Mon Sep 17 00:00:00 2001 From: seatonwan9 <seatonwan9@163.com> Date: 星期五, 28 五月 2021 19:39:12 +0800 Subject: [PATCH] 环境风险图层控制 --- src/components/LayerController/logic/EnvironmentRisk.js | 64 +++++++++++++------------------ 1 files changed, 27 insertions(+), 37 deletions(-) diff --git a/src/components/LayerController/logic/EnvironmentRisk.js b/src/components/LayerController/logic/EnvironmentRisk.js index e7478e7..ae50da3 100644 --- a/src/components/LayerController/logic/EnvironmentRisk.js +++ b/src/components/LayerController/logic/EnvironmentRisk.js @@ -1,8 +1,6 @@ /** - * 鐜椋庨櫓 + * 鐜椋庨櫓缁熻鍥� */ -// const EnvironmentRiskIndex = require('@components/base-page/').default - // 璇锋眰鎺ュ彛鏁版嵁 const mapApi = require('../../../api/mapApi').default // 浣跨敤灏佽鏂规硶 @@ -11,46 +9,53 @@ const echarts = require('echarts/lib/echarts') module.exports = function () { - // 瀛樻斁鐜舰鍥剧殑鏁扮粍 - let riskLayerGroup = [] + let animalService = null + // 鐜舰缁熻鍥炬暟缁� + let riskLayerGroup = null + /** - * 杩斿洖marker瀵硅薄鏁扮粍 + * 鍒濆鍖栧浘灞傛暟缁� * @param L leaflet瀵硅薄 */ this.init = async (layer, L) => { - this.animalService = new AnimalService({ + animalService = new AnimalService({ L: L, layer: layer }) - layer.addLayer(riskLayerGroup) } + /** + * 鍔犺浇鍥惧眰 + * @returns {Promise<void>} + */ this.start = async () => { - riskLayerGroup = window.layerFactory.L.featureGroup().addTo(window.layerFactory.map) - const result = await mapApi.getRiskEnterprise() + if (riskLayerGroup) { // 鍥惧眰鍏ㄩ�夋椂锛屾竻鐞嗗浘灞傛暟缁勫苟閲嶆柊鍔犺浇 + riskLayerGroup.remove() + riskLayerGroup = null + } + riskLayerGroup = animalService.L.featureGroup().addTo(animalService.layer) + const result = await mapApi.getEnvironmentRisk() const features = result.features - for (var i = 0; i < features.length; i++) { + for (let i = 0; i < features.length; i++) { const feature = features[i] const geometry = feature.geometry const properties = feature.properties const qyId = properties.QY_ID - // const qyJc = properties.QY_JC const distract = properties.DISTRACT const coordinates = geometry.coordinates if (distract !== '闀挎睙娌跨嚎') { continue } - window.layerFactory.L.marker([coordinates[1], coordinates[0]], { - icon: this.animalService.L.divIcon({ + animalService.L.marker([coordinates[1], coordinates[0]], { + icon: animalService.L.divIcon({ className: '', iconAnchor: [15, 45], iconSize: [40, 40], html: '<div style="width: 40px; height: 40px; background-color: rgba(255,255,255,1); position: relative; border-radius: 50%;"></div>' }) }).addTo(riskLayerGroup) - // this.animalService.layer.addLayer(bgMarker) - window.layerFactory.L.marker([coordinates[1], coordinates[0]], { - icon: this.animalService.L.divIcon({ + animalService.L.marker([coordinates[1], coordinates[0]], { + icon: animalService.L.divIcon({ className: '', iconAnchor: [30, 60], iconSize: [70, 70], @@ -61,35 +66,23 @@ } } + /** + * 娓呴櫎鍥惧眰 + */ this.destory = () => { if (riskLayerGroup) { riskLayerGroup.remove() + riskLayerGroup = null } } /** - * tips - * @param layer - * @returns {string} - */ - this.bindTooltip = (layer) => { - } - - /** - * 鐐瑰嚮寮圭獥 - * @param e - */ - this.clickListener = (e) => { - } - - /** - * 鐜舰楗煎浘 + * Echarts鐜舰楗煎浘 * @param properties */ function chartRender (properties) { const qyId = properties.QY_ID const qyjc = properties.QY_JC - // const qyQc = properties.QY_QC const num = properties.QY_NUM const oneLevel = properties.QY_ONELEVEL const twoLevel = properties.QY_TWOLEVEL @@ -150,8 +143,5 @@ }] } o.setOption(option) - /* o.on('click', function (params) { - map.flyTo(L.latLng([params.data.y, params.data.x]), 15) - }) */ } } -- Gitblit v1.8.0