重构风险点隐患点显示逻辑
This commit is contained in:
@@ -11,15 +11,14 @@ import config from '@/config/config.json';
|
||||
import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils';
|
||||
import AdministrativeDivision from './AdministrativeDivision.vue';
|
||||
import { useViewerStore } from '@/stores/useViewerStore';
|
||||
import { useLoadingInformationStore } from '@/stores/useLoadingInformation';
|
||||
|
||||
onBeforeMount(() => {
|
||||
// 初始化为false
|
||||
useViewerStore().setViewerLoadingCompleted(false)
|
||||
|
||||
// 清除viewer相关资源
|
||||
if (CesiumUtilsSingleton.getViewer()) {
|
||||
CesiumUtilsSingleton.clearAllResources('all')
|
||||
}
|
||||
// 重置状态
|
||||
useLoadingInformationStore().resetStatue()
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
@@ -27,6 +26,38 @@ onMounted(() => {
|
||||
containerId: 'map-container'
|
||||
})
|
||||
|
||||
// 注册全局点击监听器
|
||||
CesiumUtilsSingleton.clickLayer((pickedObject: any) => {
|
||||
if (pickedObject && pickedObject.id && (typeof pickedObject.id === 'string')) {
|
||||
const matchResult = pickedObject.id.match(/\d+$/)
|
||||
const id = matchResult ? parseInt(matchResult[0]) : -1
|
||||
|
||||
// 当id改变时候,重置状态
|
||||
if (useLoadingInformationStore().getHiddenPointId() !== id && useLoadingInformationStore().getRiskPointId() !== id) {
|
||||
useLoadingInformationStore().resetStatue()
|
||||
}
|
||||
|
||||
// 点击对象
|
||||
useLoadingInformationStore().setClickObject(pickedObject)
|
||||
|
||||
// 隐患点
|
||||
if (pickedObject.id.startsWith(config.prefix.hiddenDangerPointId)) {
|
||||
useLoadingInformationStore().setHiddenPointId(id)
|
||||
}
|
||||
|
||||
// 风险点
|
||||
else if (pickedObject.id.startsWith(config.prefix.riskPointId)) {
|
||||
useLoadingInformationStore().setRiskPointId(id)
|
||||
}else {
|
||||
// 重置状态
|
||||
useLoadingInformationStore().resetStatue()
|
||||
}
|
||||
} else {
|
||||
// 重置状态
|
||||
useLoadingInformationStore().resetStatue()
|
||||
}
|
||||
})
|
||||
|
||||
// 更新完成状态
|
||||
useViewerStore().setViewerLoadingCompleted(true)
|
||||
CesiumUtilsSingleton.viewToTarget(config.defaultPosition as [number, number, number]);
|
||||
|
||||
Reference in New Issue
Block a user