From df1fb2aea3e3001dac0c22d7c3d6dfe6dbdaa6a3 Mon Sep 17 00:00:00 2001 From: wzy-warehouse <18135009705@163.com> Date: Tue, 14 Apr 2026 17:05:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B7=BB=E5=8A=A0gsojson?= =?UTF-8?q?=E7=9A=84isdefault=EF=BC=8C=E6=96=B9=E4=BE=BF=E9=87=8D=E7=BD=AE?= =?UTF-8?q?=E5=9C=BA=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/component/map/AdministrativeDivision.vue | 2 +- src/component/rain-earthquake/HiddenPointComponent.vue | 1 + src/component/rain-earthquake/LoadingPoints.vue | 4 +++- src/component/rain-earthquake/RiskPointComponent.vue | 1 + src/hooks/usePointsHandle.ts | 6 ++++-- src/utils/cesium/CesiumUtils.ts | 5 ++--- src/utils/cesium/EntityManager.ts | 1 - src/utils/cesium/PrimitiveManager.ts | 1 - 8 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/component/map/AdministrativeDivision.vue b/src/component/map/AdministrativeDivision.vue index 84e05cd..60ff0b2 100644 --- a/src/component/map/AdministrativeDivision.vue +++ b/src/component/map/AdministrativeDivision.vue @@ -19,9 +19,9 @@ const layerConfigs = areasId.map((id, index) => ({ layerId: id, geojsonData: areas[index], - isDefault: true, options: { showName: true, + isDefault: true, labelStyle: { labelText: areas[index].features[0].properties.name, center: [ diff --git a/src/component/rain-earthquake/HiddenPointComponent.vue b/src/component/rain-earthquake/HiddenPointComponent.vue index 8973601..0574f61 100644 --- a/src/component/rain-earthquake/HiddenPointComponent.vue +++ b/src/component/rain-earthquake/HiddenPointComponent.vue @@ -10,6 +10,7 @@ :get-disaster-icon="getDisasterIcon" :prefix="config.prefix.hiddenDangerPointId" :show-points="useStatusStore().getHiddenDangerPointShow()" + :is-default="true" /> diff --git a/src/component/rain-earthquake/LoadingPoints.vue b/src/component/rain-earthquake/LoadingPoints.vue index 6f1d43f..2aeb5b5 100644 --- a/src/component/rain-earthquake/LoadingPoints.vue +++ b/src/component/rain-earthquake/LoadingPoints.vue @@ -15,6 +15,7 @@ getDisasterIcon: (disasterType?: string) => string; prefix: string; showPoints: boolean; + isDefault?: boolean; }>(); // 点处理钩子 @@ -25,7 +26,8 @@ const ids: string[] = pointsHandle.addPoints( props.basePoints, props.getDisasterIcon, - props.prefix + props.prefix, + props.isDefault ); // 显示隐藏点 diff --git a/src/component/rain-earthquake/RiskPointComponent.vue b/src/component/rain-earthquake/RiskPointComponent.vue index dde45ce..587b323 100644 --- a/src/component/rain-earthquake/RiskPointComponent.vue +++ b/src/component/rain-earthquake/RiskPointComponent.vue @@ -8,6 +8,7 @@ :get-disaster-icon="getDisasterIcon" :prefix="config.prefix.riskPointId" :show-points="useStatusStore().getRiskPointShow()" + :is-default="true" /> diff --git a/src/hooks/usePointsHandle.ts b/src/hooks/usePointsHandle.ts index f408fef..31c5b7f 100644 --- a/src/hooks/usePointsHandle.ts +++ b/src/hooks/usePointsHandle.ts @@ -18,12 +18,14 @@ export const usePointsHandle = () => { * @param points - 点数据数组 * @param getDisasterIcon - 获取灾害图标的函数 * @param prefix - 前缀 + * @param isDefault - 是否为默认图元,默认false * @returns 点的ID列表 */ function addPoints( points: Point[], getDisasterIcon: (disasterType?: string) => string, - prefix: string + prefix: string, + isDefault: boolean = false ): string[] { // 设置加载配置 const options: PrimitiveOptions[] = []; @@ -48,7 +50,7 @@ export const usePointsHandle = () => { image: getDisasterIcon(point.disasterType), scale: 0.8, width: 40, - isDefault: false, + isDefault: isDefault, scaleByDistance: new NearFarScalar(500, 1, 5e5, 0.3), customProperties: { verticalOrigin: VerticalOrigin.BOTTOM, diff --git a/src/utils/cesium/CesiumUtils.ts b/src/utils/cesium/CesiumUtils.ts index 78d82b0..0f1ae4b 100644 --- a/src/utils/cesium/CesiumUtils.ts +++ b/src/utils/cesium/CesiumUtils.ts @@ -197,7 +197,7 @@ export class CesiumUtils { } /** - * 批量添加 Primitive(优化版本) + * 批量添加 Primitive * - 按类型分组后批量创建,减少 scene.primitives.add 调用次数 * - 同类型的多个实例合并到一个 Primitive 或 BillboardCollection 中 * @param primitives - Primitive 配置选项数组 @@ -384,13 +384,12 @@ export class CesiumUtils { /** * 批量添加GeoJSON图层 - * @param layerConfigs - 图层配置数组,每个元素包含 layerId、geojsonData、isDefault 和 options + * @param layerConfigs - 图层配置数组,每个元素包含 layerId、geojsonData 和 options */ async batchAddGeoJsonLayers( layerConfigs: Array<{ layerId: string; geojsonData: CustomizeGeoJsonDataSource; - isDefault?: boolean; options?: GeoJsonOptions; }> ): Promise { diff --git a/src/utils/cesium/EntityManager.ts b/src/utils/cesium/EntityManager.ts index 0414b66..c03ea14 100644 --- a/src/utils/cesium/EntityManager.ts +++ b/src/utils/cesium/EntityManager.ts @@ -136,7 +136,6 @@ export class EntityManager { */ clearAllEntities(clearType: 'default' | 'custom' | 'all' = 'custom'): void { const targetIds = this.#getTargetIdsByType(clearType); - targetIds.forEach((id) => { const entity = this.#viewer.entities.getById(id); if (entity) this.#viewer.entities.remove(entity); diff --git a/src/utils/cesium/PrimitiveManager.ts b/src/utils/cesium/PrimitiveManager.ts index 0eaa1be..f95945c 100644 --- a/src/utils/cesium/PrimitiveManager.ts +++ b/src/utils/cesium/PrimitiveManager.ts @@ -103,7 +103,6 @@ export class PrimitiveManager { */ clearAllPrimitives(clearType: 'default' | 'custom' | 'all' = 'custom'): void { const targetMap = this.#getTargetMapByType(clearType); - targetMap.forEach((primitive) => { this.#viewer.scene.primitives.remove(primitive); });