| | |
| | | <div class="height-100 width-100 cesium" id="cesiumContainer"></div> |
| | | <div v-if="centerConfig.type && !centerConfig.latitude" class="pointLongitude">在地图上点击绘制项目中心点</div> |
| | | <div class="search"> |
| | | <a-auto-complete |
| | | v-model:value="searchText" |
| | | style="width: 200px" |
| | | placeholder="请输入地址" |
| | | @select="enter" |
| | | @change="searchLocation" |
| | | :options='resultList' |
| | | > |
| | | </a-auto-complete> |
| | | <a-auto-complete v-if="show" v-model:value="searchText" style="width: 200px;height: 100%;" placeholder="请输入地址" @select="enter" |
| | | @change="searchLocation" :options='resultList'> |
| | | </a-auto-complete> |
| | | <span class="search-icon" @click="() => show = !show"> |
| | | <SearchOutlined style="fontSize:24px; color: blue;" /> |
| | | </span> |
| | | </div> |
| | | |
| | | <div class="zoon"> |
| | | <span class="zoon-in" @mousedown="handleMouseDown(zoonIn)" @mouseup="handleMouseUp"> |
| | | <PlusOutlined style="fontSize:24px; color: black;" /> |
| | | </span> |
| | | |
| | | <span class="zoon-out" @mousedown="handleMouseDown(zoonOut)" @mouseup="handleMouseUp"> |
| | | <MinusOutlined style="fontSize:24px; color: black;" /> |
| | | </span> |
| | | </div> |
| | | <div class="switch"> |
| | | <div class="2d" v-if="dimension === 2" @click="switchDimension('3D')">2D</div> |
| | |
| | | import _ from 'lodash' |
| | | import { cesiumOperation } from '/@/hooks/use-cesium-tsa' |
| | | import { gaodeSearch } from '/@/api/gaode' |
| | | import { SearchOutlined, PlusOutlined, MinusOutlined } from '@ant-design/icons-vue' |
| | | import { useMyStore } from '/@/store' |
| | | import * as Cesium from 'cesium' |
| | | type result = { |
| | | label: string, |
| | | value: string, |
| | | location: string, |
| | | district:string, |
| | | district: string, |
| | | } |
| | | const searchText = ref('') |
| | | const resultList = ref<result[]>([]) |
| | | const timer = ref<any>(null) |
| | | const store = useMyStore() |
| | | const centerConfig = computed(() => { |
| | | return store.state.map.centerConfig |
| | | }) |
| | | const show = ref(false) |
| | | const search = async () => { |
| | | resultList.value = [] |
| | | const params = { |
| | |
| | | if (res.code !== 0) return |
| | | if (res.data.tips.length > 0) { |
| | | res.data.tips.shift() |
| | | resultList.value = res.data.tips.map((v:any) => { |
| | | resultList.value = res.data.tips.map((v: any) => { |
| | | return { |
| | | value: `${v.name}(${v.district})`, |
| | | label: v.name, |
| | |
| | | } |
| | | } |
| | | const searchLocation = _.debounce(search, 500) |
| | | const { flyTo, addPoint, removeById, switchModel, dimension } = cesiumOperation() |
| | | const enter = (e:string) => { |
| | | const { flyTo, addPoint, removeById, switchModel, dimension, zoonIn, zoonOut } = cesiumOperation() |
| | | const enter = (e: string) => { |
| | | removeById('key') |
| | | const filterItem = resultList.value.find(v => v.value === e) |
| | | const [longitude, latitude] = filterItem?.location.split(',') |
| | |
| | | addPoint({ ...pointParams, ...params }) |
| | | flyTo(params) |
| | | } |
| | | const switchDimension = (type:string) => { |
| | | const switchDimension = (type: string) => { |
| | | switchModel(type) |
| | | } |
| | | const handleMouseDown = (fn:Function) => { |
| | | // clearInterval(timer.value) |
| | | timer.value = setInterval(() => { |
| | | fn(10) |
| | | }, 100) |
| | | } |
| | | const handleMouseUp = () => { |
| | | clearInterval(timer.value) |
| | | } |
| | | |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | |
| | | text-align: center; |
| | | font-size: 16px; |
| | | } |
| | | |
| | | .search { |
| | | position: absolute; |
| | | top: 40px; |
| | | right: 20px; |
| | | color: #fff; |
| | | font-size: 16px; |
| | | display: flex; |
| | | align-items: center; |
| | | height: 32px; |
| | | .search-icon { |
| | | padding: 5px; |
| | | background-color: #fff; |
| | | height: 32px; |
| | | cursor: pointer; |
| | | } |
| | | } |
| | | |
| | | .zoon { |
| | | position: absolute; |
| | | right: 20px; |
| | | bottom: 340px; |
| | | color: #fff; |
| | | font-size: 16px; |
| | | display: flex; |
| | | align-items: center; |
| | | flex-direction: column; |
| | | height: 32px; |
| | | &-in, &-out { |
| | | padding: 5px; |
| | | background-color: #fff; |
| | | height: 32px; |
| | | cursor: pointer; |
| | | margin-top: 10px; |
| | | } |
| | | } |
| | | |
| | | .switch { |
| | | position: absolute; |
| | | background-color: #fff; |
| | | z-index: 30; |
| | | bottom: 80px; |
| | | bottom: 400px; |
| | | font-size: 14px; |
| | | right: 20px; |
| | | cursor: pointer; |
| | | box-shadow: 0 0 4px 0 rgba(0, 0, 0, .6); |
| | | width: 28px; |
| | | height: 28px; |
| | | width: 34px; |
| | | height: 34px; |
| | | color: #4e4e4e; |
| | | font-weight: 600; |
| | | display: flex; |