From d195225b4e628e541caca0944d54fec027572a06 Mon Sep 17 00:00:00 2001 From: seatonwan9 <seatonwan9@163.com> Date: 星期日, 30 五月 2021 13:35:20 +0800 Subject: [PATCH] 治理设施测试 --- src/components/LayerController/logic/EnvironmentRisk.js | 65 +++++++++++++++++--------------- 1 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/components/LayerController/logic/EnvironmentRisk.js b/src/components/LayerController/logic/EnvironmentRisk.js index 65591ac..677e670 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,8 +9,11 @@ const echarts = require('echarts/lib/echarts') module.exports = function () { + // 鐜舰缁熻鍥炬暟缁� + let riskLayerGroup = null + /** - * 杩斿洖marker瀵硅薄鏁扮粍 + * 鍒濆鍖栧浘灞傛暟缁� * @param L leaflet瀵硅薄 */ this.init = async (layer, L) => { @@ -20,62 +21,67 @@ L: L, layer: layer }) - const result = await mapApi.getRiskEnterprise() + } + + /** + * 鍔犺浇鍥惧眰 + * @returns {Promise<void>} + */ + this.start = async () => { + if (riskLayerGroup) { // 鍥惧眰鍏ㄩ�夋椂锛屾竻鐞嗗浘灞傛暟缁勫苟閲嶆柊鍔犺浇 + riskLayerGroup.remove() + riskLayerGroup = null + } + riskLayerGroup = this.animalService.L.featureGroup().addTo(this.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({ + this.animalService.L.marker([coordinates[1], coordinates[0]], { + icon: this.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) + this.animalService.L.marker([coordinates[1], coordinates[0]], { + icon: this.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 + * Echarts鐜舰楗煎浘 + * @param properties */ - this.clickListener = (e) => { - - } - 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 @@ -98,7 +104,7 @@ { type: 'text', left: 'center', - top: '35%', + top: '43%', // 璁剧疆鐜舰鏂囧瓧鐨則op浣嶇疆 style: { text: num, textAlign: 'center', @@ -136,8 +142,5 @@ }] } o.setOption(option) - /* o.on('click', function (params) { - map.flyTo(L.latLng([params.data.y, params.data.x]), 15) - }) */ } } -- Gitblit v1.8.0