添加name记录

This commit is contained in:
wzy-warehouse
2026-04-27 21:36:37 +08:00
parent 4c576132db
commit e47a660590
16 changed files with 57 additions and 40 deletions
+2 -2
View File
@@ -24,7 +24,7 @@
onMounted(() => {
// 加载点
const ids: string[] = pointsHandle.addPoints(
const result: { ids: string[]; names: string[] } = pointsHandle.addPoints(
props.basePoints,
props.getDisasterIcon,
props.prefix,
@@ -34,7 +34,7 @@
// 记录id
useLoadingResourceStore().addLoadingResource(
props.loadingResourceField!,
ids
result
);
});
</script>
+1 -1
View File
@@ -47,7 +47,7 @@
// 记录行政区划id
useLoadingResourceStore().addLoadingResource(
LoadingResource.ADMINISTRATIVE_DIVISION,
areasId
{ ids: areasId, names: [] } // 此处name不进行记录
);
});
@@ -108,14 +108,14 @@
CesiumUtilsSingleton.batchShowPrimitives(
useLoadingResourceStore().getLoadingResource(
LoadingResource.HIDDEN_DANGER_POINT
)
).ids
);
} else {
// 隐藏隐患点
CesiumUtilsSingleton.batchHidePrimitives(
useLoadingResourceStore().getLoadingResource(
LoadingResource.HIDDEN_DANGER_POINT
)
).ids
);
}
}
@@ -98,13 +98,13 @@
CesiumUtilsSingleton.batchShowPrimitives(
useLoadingResourceStore().getLoadingResource(
LoadingResource.RISK_POINT
)
).ids
);
} else {
CesiumUtilsSingleton.batchHidePrimitives(
useLoadingResourceStore().getLoadingResource(
LoadingResource.RISK_POINT
)
).ids
);
}
}
@@ -3,9 +3,7 @@
<div>
<!-- 加载桥梁点 -->
<LoadingPoints
v-if="
useStatusStore().appLoadingCompleted && bridgeList.length > 0
"
v-if="useStatusStore().appLoadingCompleted && bridgeList.length > 0"
:base-points="bridgeList"
:get-disaster-icon="getDisasterIcon"
:prefix="config.prefix.bridgePointId"
@@ -101,16 +99,14 @@
if (newValue) {
// 显示桥梁点
CesiumUtilsSingleton.batchShowPrimitives(
useLoadingResourceStore().getLoadingResource(
LoadingResource.BRIDGE
)
useLoadingResourceStore().getLoadingResource(LoadingResource.BRIDGE)
.ids
);
} else {
// 隐藏桥梁点
CesiumUtilsSingleton.batchHidePrimitives(
useLoadingResourceStore().getLoadingResource(
LoadingResource.BRIDGE
)
useLoadingResourceStore().getLoadingResource(LoadingResource.BRIDGE)
.ids
);
}
}
@@ -103,14 +103,14 @@
CesiumUtilsSingleton.batchShowPrimitives(
useLoadingResourceStore().getLoadingResource(
LoadingResource.DANGEROUS_SOURCE
)
).ids
);
} else {
// 隐藏危险源
CesiumUtilsSingleton.batchHidePrimitives(
useLoadingResourceStore().getLoadingResource(
LoadingResource.DANGEROUS_SOURCE
)
).ids
);
}
}
@@ -104,14 +104,14 @@
CesiumUtilsSingleton.batchShowPrimitives(
useLoadingResourceStore().getLoadingResource(
LoadingResource.EMERGENCY_SHELTER
)
).ids
);
} else {
// 隐藏避难所
CesiumUtilsSingleton.batchHidePrimitives(
useLoadingResourceStore().getLoadingResource(
LoadingResource.EMERGENCY_SHELTER
)
).ids
);
}
}
@@ -103,14 +103,14 @@
CesiumUtilsSingleton.batchShowPrimitives(
useLoadingResourceStore().getLoadingResource(
LoadingResource.FIRE_STATION
)
).ids
);
} else {
// 隐藏消防站
CesiumUtilsSingleton.batchHidePrimitives(
useLoadingResourceStore().getLoadingResource(
LoadingResource.FIRE_STATION
)
).ids
);
}
}
@@ -100,11 +100,13 @@
// 显示医院
CesiumUtilsSingleton.batchShowPrimitives(
useLoadingResourceStore().getLoadingResource(LoadingResource.HOSPITAL)
.ids
);
} else {
// 隐藏医院
CesiumUtilsSingleton.batchHidePrimitives(
useLoadingResourceStore().getLoadingResource(LoadingResource.HOSPITAL)
.ids
);
}
}
@@ -99,12 +99,16 @@
if (newValue) {
// 显示水库
CesiumUtilsSingleton.batchShowPrimitives(
useLoadingResourceStore().getLoadingResource(LoadingResource.RESERVOIR)
useLoadingResourceStore().getLoadingResource(
LoadingResource.RESERVOIR
).ids
);
} else {
// 隐藏水库
CesiumUtilsSingleton.batchHidePrimitives(
useLoadingResourceStore().getLoadingResource(LoadingResource.RESERVOIR)
useLoadingResourceStore().getLoadingResource(
LoadingResource.RESERVOIR
).ids
);
}
}
@@ -100,11 +100,13 @@
// 显示学校
CesiumUtilsSingleton.batchShowPrimitives(
useLoadingResourceStore().getLoadingResource(LoadingResource.SCHOOL)
.ids
);
} else {
// 隐藏学校
CesiumUtilsSingleton.batchHidePrimitives(
useLoadingResourceStore().getLoadingResource(LoadingResource.SCHOOL)
.ids
);
}
}
@@ -3,9 +3,7 @@
<div>
<!-- 加载物资储备点 -->
<LoadingPoints
v-if="
useStatusStore().appLoadingCompleted && storePointsList.length > 0
"
v-if="useStatusStore().appLoadingCompleted && storePointsList.length > 0"
:base-points="storePointsList"
:get-disaster-icon="getDisasterIcon"
:prefix="config.prefix.storePointsPointId"
@@ -103,14 +101,14 @@
CesiumUtilsSingleton.batchShowPrimitives(
useLoadingResourceStore().getLoadingResource(
LoadingResource.STORE_POINTS
)
).ids
);
} else {
// 隐藏物资储备点
CesiumUtilsSingleton.batchHidePrimitives(
useLoadingResourceStore().getLoadingResource(
LoadingResource.STORE_POINTS
)
).ids
);
}
}
@@ -3,7 +3,9 @@
<div>
<!-- 加载地铁站点点位 -->
<LoadingPoints
v-if="useStatusStore().appLoadingCompleted && subwayStationList.length > 0"
v-if="
useStatusStore().appLoadingCompleted && subwayStationList.length > 0
"
:base-points="subwayStationList"
:get-disaster-icon="getDisasterIcon"
:prefix="config.prefix.subwayStationPointId"
@@ -99,12 +101,16 @@
if (newValue) {
// 显示地铁站点
CesiumUtilsSingleton.batchShowPrimitives(
useLoadingResourceStore().getLoadingResource(LoadingResource.SUBWAY_STATION)
useLoadingResourceStore().getLoadingResource(
LoadingResource.SUBWAY_STATION
).ids
);
} else {
// 隐藏地铁站点
CesiumUtilsSingleton.batchHidePrimitives(
useLoadingResourceStore().getLoadingResource(LoadingResource.SUBWAY_STATION)
useLoadingResourceStore().getLoadingResource(
LoadingResource.SUBWAY_STATION
).ids
);
}
}
+7 -3
View File
@@ -26,12 +26,13 @@ export const usePointsHandle = () => {
getDisasterIcon: (disasterType?: string) => string,
prefix: string,
isDefault: boolean = false
): string[] {
): { ids: string[]; names: string[] } {
// 设置加载配置
const options: PrimitiveOptions[] = [];
// 存放id
// 存放id、name
const ids: string[] = [];
const names: string[] = [];
points.forEach((point) => {
try {
@@ -42,7 +43,10 @@ export const usePointsHandle = () => {
const position = Cartesian3.fromDegrees(point.lon, point.lat, 10);
const id = `${prefix}${point.id}`;
const name = point.name!;
ids.push(id);
names.push(name);
options.push({
id: id,
type: 'billboard',
@@ -65,7 +69,7 @@ export const usePointsHandle = () => {
// 批量创建图层
CesiumUtilsSingleton.addPrimitivesBatch(options);
return ids;
return { ids, names };
}
return { addPoints };
+8 -5
View File
@@ -4,12 +4,15 @@ import { ref, type Ref } from 'vue';
// 存储按需加载的数据
export const useLoadingResourceStore = defineStore('loadingResource', () => {
const loadingResource: Ref<Partial<Record<LoadingResource, string[]>>> = ref(
{}
);
const loadingResource: Ref<
Partial<Record<LoadingResource, { ids: string[]; names: string[] }>>
> = ref({});
// 添加数据
const addLoadingResource = (key: LoadingResource, value: string[]) => {
const addLoadingResource = (
key: LoadingResource,
value: { ids: string[]; names: string[] }
) => {
loadingResource.value[key] = value;
};
@@ -24,7 +27,7 @@ export const useLoadingResourceStore = defineStore('loadingResource', () => {
* 获取数据
*/
const getLoadingResource = (key: LoadingResource) => {
return loadingResource.value[key] || [];
return loadingResource.value[key] || { ids: [], names: [] };
};
return {
+2
View File
@@ -12,4 +12,6 @@ export interface Point {
geom?: string;
/** 灾害类型 */
disasterType?: string;
/** 名称 */
name?: string;
}