| | |
| | | import cesiumOperation from '@/utils/cesium-tsa' |
| | | import EventOverviewDetail from '@/views/Home/EventOverviewDetail/EventOverviewDetail.vue' |
| | | import AINowFly from '@/views/Home/AINowFly.vue' |
| | | import { getMapCenterPoint } from '@/utils/cesium/mapUtil' |
| | | import { getAreaCodeApi } from '@/api/home' |
| | | import { getDroneSuggest } from '@/api/home/common' |
| | | import { MAP_LEVEL } from '@/const/drc' |
| | | import _ from 'lodash' |
| | | |
| | | const store = useStore() |
| | | const { _init, viewerDestory } = cesiumOperation() |
| | |
| | | viewerDestory() |
| | | }) |
| | | |
| | | // 获取飞行建议 |
| | | function getFlySuggestion(){ |
| | | const viewer = window.$viewer |
| | | const {longitude,latitude} = getMapCenterPoint(viewer) |
| | | let height = viewer.camera.positionCartographic.height; |
| | | if (height > MAP_LEVEL[0].heightRange[1]) { |
| | | store.commit('setFlySuggest', {}) |
| | | return |
| | | } |
| | | const params = { location: longitude + ',' + latitude} |
| | | getAreaCodeApi(params).then(res => { |
| | | const { adcode:areaCode } = res.data.data.regeocode.addressComponent |
| | | if (!areaCode) return |
| | | return getDroneSuggest({areaCode}) |
| | | }).then(res => { |
| | | const setFlySuggest = _.pick(res.data.data,['windPower','flightAdvice']) || {} |
| | | store.commit('setFlySuggest', setFlySuggest) |
| | | }) |
| | | } |
| | | |
| | | onBeforeUnmount(() =>{ |
| | | window.$viewer.camera.moveEnd.removeEventListener(getFlySuggestion); |
| | | }) |
| | | |
| | | onMounted(() => { |
| | | _init('cesium') |
| | | nextTick(() => { |
| | | getFlySuggestion() |
| | | window.$viewer.camera.moveEnd.addEventListener(getFlySuggestion); |
| | | }) |
| | | }) |
| | | </script> |