| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import * as Cesium from 'cesium' |
| | | |
| | | import { onBeforeUnmount, onMounted, watch } from 'vue' |
| | | import { PublicCesium } from '@/utils/cesium/publicCesium' |
| | | import { loadJaAdminBoundary, removeJaAdminBoundary } from '@/utils/cesium/adminBoundary' |
| | |
| | | }) |
| | | } |
| | | |
| | | const zoomToAdminBoundary = async () => { |
| | | if (!viewer) return |
| | | const resolveSources = () => { |
| | | if (adminBoundarySources) return adminBoundarySources |
| | | const boundarySource = viewer.dataSources.getByName(ADMIN_BOUNDARY_NAMES.boundary)?.[0] ?? null |
| | | const lineSource = viewer.dataSources.getByName(ADMIN_BOUNDARY_NAMES.line)?.[0] ?? null |
| | | const labelSource = viewer.dataSources.getByName(ADMIN_BOUNDARY_NAMES.label)?.[0] ?? null |
| | | if (boundarySource || lineSource || labelSource) { |
| | | adminBoundarySources = { boundarySource, lineSource, labelSource } |
| | | } |
| | | return adminBoundarySources |
| | | } |
| | | let sources = resolveSources() |
| | | if (!sources?.boundarySource) { |
| | | sources = await loadJaAdminBoundary(viewer, { zoomTo: false }) |
| | | adminBoundarySources = sources |
| | | } |
| | | const target = sources?.boundarySource |
| | | if (!target) return |
| | | await viewer.flyTo(target, { |
| | | duration: 0, |
| | | offset: new Cesium.HeadingPitchRange(0, Cesium.Math.toRadians(-75), 0), |
| | | }) |
| | | } |
| | | |
| | | const getMap = () => ({ viewer, publicCesium: viewInstance }) |
| | | const getViewer = () => viewer |
| | | const getPublicCesium = () => viewInstance |
| | | |
| | | defineExpose({ getMap, getViewer, getPublicCesium, setAdminBoundaryVisible }) |
| | | defineExpose({ getMap, getViewer, getPublicCesium, setAdminBoundaryVisible, zoomToAdminBoundary }) |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |