记录基础信息
This commit is contained in:
@@ -24,7 +24,8 @@
|
||||
|
||||
onMounted(() => {
|
||||
// 加载点
|
||||
const result: { ids: string[]; names: string[] } = pointsHandle.addPoints(
|
||||
const result: { ids: string[]; info: Record<string, unknown>[] } =
|
||||
pointsHandle.addPoints(
|
||||
props.basePoints,
|
||||
props.getDisasterIcon,
|
||||
props.prefix,
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
// 记录行政区划id
|
||||
useLoadingResourceStore().addLoadingResource(
|
||||
LoadingResource.ADMINISTRATIVE_DIVISION,
|
||||
{ ids: areasId, names: [] } // 此处name不进行记录
|
||||
{ ids: areasId, info: [] } // 此处info不进行记录
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -26,13 +26,13 @@ export const usePointsHandle = () => {
|
||||
getDisasterIcon: (disasterType?: string) => string,
|
||||
prefix: string,
|
||||
isDefault: boolean = false
|
||||
): { ids: string[]; names: string[] } {
|
||||
): { ids: string[]; info: Record<string, unknown>[] } {
|
||||
// 设置加载配置
|
||||
const options: PrimitiveOptions[] = [];
|
||||
|
||||
// 存放id、name
|
||||
// 存放id、name、经纬度
|
||||
const ids: string[] = [];
|
||||
const names: string[] = [];
|
||||
const info: Record<string, unknown>[] = [];
|
||||
|
||||
points.forEach((point) => {
|
||||
try {
|
||||
@@ -43,9 +43,8 @@ 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);
|
||||
info.push({ id, name: point.name!, lon: point.lon, lat: point.lat });
|
||||
|
||||
options.push({
|
||||
id: id,
|
||||
@@ -69,7 +68,7 @@ export const usePointsHandle = () => {
|
||||
// 批量创建图层
|
||||
CesiumUtilsSingleton.addPrimitivesBatch(options);
|
||||
|
||||
return { ids, names };
|
||||
return { ids, info };
|
||||
}
|
||||
|
||||
return { addPoints };
|
||||
|
||||
@@ -5,13 +5,18 @@ import { ref, type Ref } from 'vue';
|
||||
// 存储按需加载的数据
|
||||
export const useLoadingResourceStore = defineStore('loadingResource', () => {
|
||||
const loadingResource: Ref<
|
||||
Partial<Record<LoadingResource, { ids: string[]; names: string[] }>>
|
||||
Partial<
|
||||
Record<
|
||||
LoadingResource,
|
||||
{ ids: string[]; info: Record<string, unknown>[] }
|
||||
>
|
||||
>
|
||||
> = ref({});
|
||||
|
||||
// 添加数据
|
||||
const addLoadingResource = (
|
||||
key: LoadingResource,
|
||||
value: { ids: string[]; names: string[] }
|
||||
value: { ids: string[]; info: Record<string, unknown>[] }
|
||||
) => {
|
||||
loadingResource.value[key] = value;
|
||||
};
|
||||
@@ -27,10 +32,11 @@ export const useLoadingResourceStore = defineStore('loadingResource', () => {
|
||||
* 获取数据
|
||||
*/
|
||||
const getLoadingResource = (key: LoadingResource) => {
|
||||
return loadingResource.value[key] || { ids: [], names: [] };
|
||||
return loadingResource.value[key] || { ids: [], info: [] };
|
||||
};
|
||||
|
||||
return {
|
||||
loadingResource,
|
||||
getLoadingResource,
|
||||
addLoadingResource,
|
||||
removeLoadingResource,
|
||||
|
||||
Reference in New Issue
Block a user