From 5fdaf3cff8add48bb5c1f0da74378b271f3cdbdf Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Mon, 07 Apr 2025 21:41:03 +0800
Subject: [PATCH] feat: 选择性清除实体
---
src/views/Home/useMapAggregation/useMapAggregation.js | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/views/Home/useMapAggregation/useMapAggregation.js b/src/views/Home/useMapAggregation/useMapAggregation.js
index f28e071..7d0da18 100644
--- a/src/views/Home/useMapAggregation/useMapAggregation.js
+++ b/src/views/Home/useMapAggregation/useMapAggregation.js
@@ -215,8 +215,9 @@
//散点机巢
function splashed(row) {
- row.splashedList.forEach(item => {
+ row.splashedList.forEach((item,index) => {
viewer.entities.add({
+ id: `aggregation-splashed-${index}`,
position: Cesium.Cartesian3.fromDegrees(item.longitude, item.latitude),
label: {
// 随机整数
@@ -283,11 +284,12 @@
}
});
// 遍历特征并添加实体
- featuresList.forEach(feature => {
+ featuresList.forEach((feature,index) => {
if (!feature.position) return;
const position = Cesium.Cartesian3.fromDegrees(feature.position[0], feature.position[1]);
viewer.entities.add({
position: position,
+ id: `aggregation-name-${index}`,
label: {
text: feature.name,
font: '14pt Source Han Sans CN',
@@ -300,7 +302,7 @@
},
});
viewer.entities.add({
- id: feature.id,
+ id: `aggregation-count-${index}`,
position: position,
label: {
text: (feature.data.total_device_count || 0).toString(),
@@ -415,7 +417,11 @@
// 移除 点 和 gjson 实体
const removeEntities = () => {
viewer.dataSources?.removeAll(true);
- viewer.entities?.removeAll();
+ // viewer.entities?.removeAll();
+ const entitiesIDs = viewer.entities.values.map(i=>i.id)
+ entitiesIDs.forEach(item => {
+ item.includes('aggregation-') && viewer.entities.removeById(item)
+ })
};
// 移除弹框标签
const removeLabel = () => {
--
Gitblit v1.9.3