From adc9abd145c24f2d3e7033bb738e1e8641eaf4cf Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期二, 02 九月 2025 17:30:43 +0800 Subject: [PATCH] 2025.9.2 --- src/utils/map/marks.js | 38 +++++++++++++++++++++++--------------- 1 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/utils/map/marks.js b/src/utils/map/marks.js index ed0c807..0b1ccce 100644 --- a/src/utils/map/marks.js +++ b/src/utils/map/marks.js @@ -3,8 +3,6 @@ */ import { map } from './index_old'; -import sector from './sector'; -import { DialogUtil } from './dialog'; import { useToolboxStore } from '@/stores/toolbox'; const toolboxStore = useToolboxStore(); @@ -21,16 +19,13 @@ if (!toolboxStore.dataMarkerStatus) { return; } - if (_massMarks) { - map.remove(_massMarks); - _massMarks = undefined; - } + this.clearMassMarks(); const lnglats = fDatas.lnglats_GD; var data = []; for (let i = 0; i < lnglats.length; i++) { data.push({ lnglat: lnglats[i], //鐐规爣璁颁綅缃� - name: `${fDatas.times[i]}<br/>${_factor.factorName}: ${_factor.datas[i].factorData} mg/m鲁`, + name: `${fDatas.times[i]}<br/>${_factor.factorName}: ${_factor.datas[i].factorData} 渭g/m鲁`, id: i }); } @@ -77,14 +72,27 @@ _massMarks = massMarks; map.add(massMarks); }, + clearMassMarks() { + if (_massMarks) { + map.remove(_massMarks); + _massMarks = undefined; + } + }, - createLabelMarks(img, dataList) { + /** + * 鍒涘缓鏍囪鐐� + * @param {string | Array} img 鍥炬爣鎴栧浘鏍囨暟缁� + * @param {Array} dataList 鐩戞祴鏁版嵁 + * @param {boolean} collision 鏍囨敞閬胯 + * @returns + */ + createLabelMarks(img, dataList, collision = true, showTxt = true) { // eslint-disable-next-line no-undef const layer = new AMap.LabelsLayer({ zooms: [3, 20], zIndex: 1000, // 寮�鍚爣娉ㄩ伩璁╋紝榛樿涓哄紑鍚紝v1.4.15 鏂板灞炴�� - collision: true, + collision: collision, // 寮�鍚爣娉ㄦ贰鍏ュ姩鐢伙紝榛樿涓哄紑鍚紝v1.4.15 鏂板灞炴�� animation: true }); @@ -102,25 +110,25 @@ zIndex: 10, icon: { type: 'image', - image: img, + image: typeof img === 'string' ? img : img[i], // clipOrigin: [14, 92], // clipSize: [50, 68], - size: [24, 24], + size: [30, 30], anchor: 'bottom-center', angel: 0, retina: true }, text: { - content: data.name, + content: showTxt ? data.name : '', direction: 'top', offset: [0, -5], style: { - fontSize: 15, + fontSize: 16, fontWeight: 'normal', fillColor: '#fff', strokeColor: '#333', - strokeWidth: 2 - // backgroundColor: '#b1009b' + strokeWidth: 0, + backgroundColor: '#122b54a9' } } }; -- Gitblit v1.9.3