| | |
| | | import * as Cesium from 'cesium' |
| | | import aggregationImg from '@/assets/images/home/useUavHome/aggregation.png' |
| | | import eventAggregationImg from '@/assets/images/home/useUavHome/eventAggregationImg.png' |
| | | import uavImg from '@/assets/images/home/useUavHome/uavImg.png' |
| | | |
| | | import eventImg from '@/assets/images/home/useEventOperate/event.png' |
| | | import eventSingle from '@/assets/images/home/useEventOperate/eventSingle.png' |
| | | |
| | | import DevicePopUpBox from '@/views/Home/useMapAggregation/DevicePopUpBox.vue' |
| | | import EventPopUpBox from '@/views/Home/useMapAggregation/EventPopUpBox.vue' |
| | |
| | | export const useMapAggregation = type => { |
| | | const { flyTo } = cesiumOperation() |
| | | |
| | | const singleImg = type === 'device' ? uavImg : eventImg |
| | | const mergeImg = type === 'device' ? aggregationImg : aggregationImg |
| | | const singleImg = type === 'device' ? uavImg : eventSingle |
| | | const mergeImg = type === 'device' ? aggregationImg : eventAggregationImg |
| | | const MapPopUpBox = type === 'device' ? DevicePopUpBox : EventPopUpBox |
| | | const styleTransform = type === 'device' ? 'translateY(-50%)' : 'translate(-50%,-110%)' |
| | | |
| | |
| | | let viewer = null |
| | | let active = null |
| | | let handler = null |
| | | let positionC3 = null |
| | | let currentEntity = null |
| | | |
| | | const store = useStore() |
| | |
| | | |
| | | // 弹框位置刷新 |
| | | const labelBoxRender = () => { |
| | | if (!currentEntity) return |
| | | let dom = document.querySelector('#mapPopUpBox') |
| | | if (!dom) { |
| | | dom = getLabelDom(currentEntity.properties.customData._value.data) |
| | | } |
| | | const screenPosition = viewer.scene.cartesianToCanvasCoordinates(positionC3) |
| | | const screenPosition = viewer.scene.cartesianToCanvasCoordinates(currentEntity?.position?._value) |
| | | if (screenPosition) { |
| | | dom.style.left = `${screenPosition.x}px` |
| | | dom.style.top = `${screenPosition.y}px` |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据条件获取项 |
| | | * @param {Array} arr 数据源 |
| | | * @param {Function} condition 条件 |
| | | * @returns |
| | | */ |
| | | const findTypeItem = (arr, condition) => { |
| | | return arr.find(item => condition(item)) |
| | | } |
| | |
| | | let clickTargets = viewer.scene.drillPick(click.position).map(item => item.id) |
| | | if (!clickTargets.length) return |
| | | |
| | | let deviceAggregationFind = findTypeItem(clickTargets, (item) => item?.properties?.customData?._value?.data?.type == 'deviceAggregation') |
| | | let deviceFind = findTypeItem(clickTargets, (item) => item?.properties?.customData?._value?.data?.type == 'device') |
| | | let eventFind = findTypeItem(clickTargets, (item) => item?.properties?.customData?._value?.data?.type == 'event') |
| | | |
| | | const curEntity = deviceAggregationFind || deviceFind || eventFind |
| | | |
| | | if (!curEntity) return |
| | | |
| | | currentEntity = curEntity |
| | | const entityPosition = curEntity?.position?._value |
| | | if (!entityPosition) return |
| | | if (entityPosition) { |
| | | positionC3 = entityPosition |
| | | } |
| | | |
| | | let deviceAggregationFind = findTypeItem(clickTargets, (item) => item?.properties?.customData?._value?.data?.type === 'deviceAggregation') |
| | | let deviceFind = findTypeItem(clickTargets, (item) => item?.properties?.customData?._value?.data?.type === 'device') |
| | | let eventFind = findTypeItem(clickTargets, (item) => item?.properties?.customData?._value?.data?.type === 'event') |
| | | currentEntity = deviceAggregationFind || deviceFind || eventFind |
| | | if (!currentEntity) return |
| | | if (!currentEntity?.position?._value) return |
| | | // 一定要移除 |
| | | removeLabel() |
| | | if (deviceAggregationFind || eventFind) { |
| | | viewer.scene.postRender.addEventListener(labelBoxRender) |
| | | } |
| | | if (deviceFind) { |
| | | store.commit('setSingleUavHome', { id: '123' }) |
| | | viewer.scene.postRender.addEventListener(labelBoxRender) |
| | | } |
| | | } |
| | | |
| | |
| | | viewer = null |
| | | active = null |
| | | handler = null |
| | | positionC3 = null |
| | | currentEntity = null |
| | | } |
| | | const init = () => { |