From ba62351d90516cf6db30332cf8ba411fd7c44526 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Wed, 09 Apr 2025 16:42:59 +0800
Subject: [PATCH] feat: 智引即飞70%
---
src/views/Home/useMapAggregation/useMapAggregation.js | 27 +++++++++++----------------
1 files changed, 11 insertions(+), 16 deletions(-)
diff --git a/src/views/Home/useMapAggregation/useMapAggregation.js b/src/views/Home/useMapAggregation/useMapAggregation.js
index 1f6aeec..3b58ccf 100644
--- a/src/views/Home/useMapAggregation/useMapAggregation.js
+++ b/src/views/Home/useMapAggregation/useMapAggregation.js
@@ -235,7 +235,6 @@
id: `aggregation-splashed-${index}`,
position: Cesium.Cartesian3.fromDegrees(item.longitude, item.latitude),
label: {
- // 随机整数
text: item.nickname,
font: '12pt Source Han Sans CN',
fillColor: Cesium.Color.WHITE,
@@ -263,15 +262,12 @@
const renderOutline = item => {
item.outline &&
Cesium.GeoJsonDataSource.load(item.outline).then(dataSource => {
- viewer.dataSources.add(dataSource)
const entities = dataSource.entities.values
- entities.forEach(entity => {
- // 隐藏多边形填充
- entity.polygon.material = Cesium.Color.TRANSPARENT
- entity.polygon.outline = false // 关闭原生轮廓
+ entities.forEach((entity,index) => {
// 创建独立折线作为轮廓
const positions = entity.polygon.hierarchy.getValue().positions
viewer.entities.add({
+ id: `aggregation-outline-${index}`,
polyline: {
positions: positions,
width: 5, // 直接设置宽度
@@ -279,7 +275,6 @@
glowPower: 0.5,
color: Cesium.Color.AQUA,
}),
- clampToGround: true, // 贴地显示
},
})
})
@@ -348,10 +343,10 @@
return arrColor[++index % arrColor.length]
}
- // 加载新的 GeoJSON 数据
+ // 加载边界
Cesium.GeoJsonDataSource.load(item.gJson).then(dataSource => {
viewer.dataSources.add(dataSource)
- item.dataSource = dataSource // 保存数据源以便后续删除
+ item.BJDataSource = dataSource // 保存数据源以便后续删除
// 获取数据源中的实体
const entities = dataSource.entities.values
@@ -369,11 +364,7 @@
})
needFly && viewer.flyTo(dataSource, {
- offset: new Cesium.HeadingPitchRange(
- 0, // heading: 0 (朝向不变)
- Cesium.Math.toRadians(-60), // pitch: -90° (垂直向下)
- 0 // range: 0 (默认距离)
- ),
+ offset: new Cesium.HeadingPitchRange(0, Cesium.Math.toRadians(-60), 0),
duration: 0.5,
})
needFly = false
@@ -449,8 +440,12 @@
// 移除 点 和 gjson 实体
const removeEntities = () => {
- viewer.dataSources?.removeAll(true)
- // viewer.entities?.removeAll();
+ // dataSources移除
+ scalingJudgment.forEach(item => {
+ item.BJDataSource && viewer.dataSources.remove(item.BJDataSource)
+ item.BJDataSource = null
+ })
+ // entities移除
const entitiesIDs = viewer.entities.values.map(i => i.id)
entitiesIDs.forEach(item => {
item.includes('aggregation-') && viewer.entities.removeById(item)
--
Gitblit v1.9.3