From 3054bbce49457c82df9ad32523f3a0186e268d6f Mon Sep 17 00:00:00 2001 From: yangdelong <828900aaa> Date: 星期五, 28 五月 2021 21:17:08 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/develop' into develop --- src/components/LayerController/logic/EnvironmentRisk.js | 68 +++++++++++++++++----------------- 1 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/components/LayerController/logic/EnvironmentRisk.js b/src/components/LayerController/logic/EnvironmentRisk.js index d80ace3..ae50da3 100644 --- a/src/components/LayerController/logic/EnvironmentRisk.js +++ b/src/components/LayerController/logic/EnvironmentRisk.js @@ -1,8 +1,6 @@ /** - * 鐜椋庨櫓 + * 鐜椋庨櫓缁熻鍥� */ -// const EnvironmentRiskIndex = require('@components/BaseNav/').default - // 璇锋眰鎺ュ彛鏁版嵁 const mapApi = require('../../../api/mapApi').default // 浣跨敤灏佽鏂规硶 @@ -11,75 +9,80 @@ const echarts = require('echarts/lib/echarts') module.exports = function () { + 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 }) - const result = await mapApi.getRiskEnterprise() + } + + /** + * 鍔犺浇鍥惧眰 + * @returns {Promise<void>} + */ + this.start = async () => { + 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 } - const bgMarker = L.marker([coordinates[1], coordinates[0]], { - icon: 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>' }) - }) - layer.addLayer(bgMarker) - const chartMarker = L.marker([coordinates[1], coordinates[0]], { - icon: L.divIcon({ + }).addTo(riskLayerGroup) + animalService.L.marker([coordinates[1], coordinates[0]], { + icon: animalService.L.divIcon({ className: '', iconAnchor: [30, 60], iconSize: [70, 70], html: '<div id="qy_id_' + qyId + '" style="width: 70px; height: 70px; background-color: transparent; position: relative; border-radius: 50%;"></div>' }) - }) - layer.addLayer(chartMarker) + }).addTo(riskLayerGroup) chartRender(properties) } } /** - * tips - * @param layer - * @returns {string} + * 娓呴櫎鍥惧眰 */ - this.bindTooltip = (layer) => { - + this.destory = () => { + if (riskLayerGroup) { + riskLayerGroup.remove() + riskLayerGroup = null + } } /** - * 鐐瑰嚮寮圭獥 - * @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 @@ -140,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