/* * @Author: shuishen 1109946754@qq.com * @Date: 2025-04-15 22:41:40 * @LastEditors: shuishen 1109946754@qq.com * @LastEditTime: 2025-04-16 15:06:15 * @FilePath: \command-center-dashboard\src\hooks\useSingleDroneMap\index.js * @Description: * * Copyright (c) 2025 by shuishen, All Rights Reserved. */ import { useMapMarkers } from './useMapMarkers' import { useMapEvents } from './useMapEvents' import { useMapPopup } from './useMapPopup' /** * Cesium地图功能组合Hook * @param {Object} options - 配置选项 * @param {Function} options.fetchMarkers - 获取标注的函数 * @param {Function} options.fetchEvents - 获取事件的函数 * @param {Component} options.popupComponent - 弹窗组件 */ export function useSingleDroneMap (options = { dronePosition: {}, eventLoadType: 'data', eventPositions: [], eventApi: null, eventApiParams: {} }) { let viewer = null let currentEntity = null // 组合各个功能Hook const { initLayer, removeLayer, } = useMapMarkers(viewer, {}) const { handlerInit, removeHandler } = useMapEvents(viewer, { onEventClick: (entity) => { currentEntity = entity // 更新当前实体 addLabel() } }) const { addLabel } = useMapPopup(viewer, { currentEntity }) const init = () => { viewer = window.$viewer initLayer() handlerInit() } const removeAll = () => { removeLayer() removeHandler() removeLabel() } // 自动清理 onUnmounted(() => { removeAll() }) return { init, removeAll } }