This commit is contained in:
杨晓凡 2023-08-23 11:39:55 +08:00
parent 1103d07650
commit ff78eb366d
10 changed files with 184 additions and 17 deletions

View File

@ -6,7 +6,9 @@ module.exports = {
es6: true es6: true
}, },
globals: { globals: {
Cesium: true Cesium: true,
viewer: true,
scene: true
}, },
extends: [ extends: [
'plugin:vue/vue3-recommended', 'plugin:vue/vue3-recommended',

68
package-lock.json generated
View File

@ -12,10 +12,12 @@
"@vicons/antd": "^0.10.0", "@vicons/antd": "^0.10.0",
"@vicons/ionicons5": "^0.10.0", "@vicons/ionicons5": "^0.10.0",
"ali-oss": "^6.17.1", "ali-oss": "^6.17.1",
"animate.css": "^4.1.1",
"axios": "^0.26.1", "axios": "^0.26.1",
"dayjs": "^1.11.2", "dayjs": "^1.11.2",
"mockjs": "^1.1.0", "mockjs": "^1.1.0",
"pinia": "^2.0.13", "pinia": "^2.0.13",
"pinia-plugin-persist": "^1.0.0",
"tinymce": "^5.10.2", "tinymce": "^5.10.2",
"vue": "^3.2.16", "vue": "^3.2.16",
"vue-router": "^4.0.14", "vue-router": "^4.0.14",
@ -2243,6 +2245,11 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
}, },
"node_modules/animate.css": {
"version": "4.1.1",
"resolved": "https://registry.npmmirror.com/animate.css/-/animate.css-4.1.1.tgz",
"integrity": "sha512-+mRmCTv6SbCmtYJCN4faJMNFVNN5EuCTTprDTAo7YzIGji2KADmakjVA3+8mVDkZ2Bf09vayB35lSQIex2+QaQ=="
},
"node_modules/ansi-colors": { "node_modules/ansi-colors": {
"version": "4.1.1", "version": "4.1.1",
"resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz",
@ -8380,6 +8387,46 @@
} }
} }
}, },
"node_modules/pinia-plugin-persist": {
"version": "1.0.0",
"resolved": "https://registry.npmmirror.com/pinia-plugin-persist/-/pinia-plugin-persist-1.0.0.tgz",
"integrity": "sha512-M4hBBd8fz/GgNmUPaaUsC29y1M09lqbXrMAHcusVoU8xlQi1TqgkWnnhvMikZwr7Le/hVyMx8KUcumGGrR6GVw==",
"dependencies": {
"vue-demi": "^0.12.1"
},
"peerDependencies": {
"@vue/composition-api": "^1.0.0",
"pinia": "^2.0.0",
"vue": "^2.0.0 || >=3.0.0"
},
"peerDependenciesMeta": {
"@vue/composition-api": {
"optional": true
}
}
},
"node_modules/pinia-plugin-persist/node_modules/vue-demi": {
"version": "0.12.5",
"resolved": "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.12.5.tgz",
"integrity": "sha512-BREuTgTYlUr0zw0EZn3hnhC3I6gPWv+Kwh4MCih6QcAeaTlaIX0DwOVN0wHej7hSvDPecz4jygy/idsgKfW58Q==",
"hasInstallScript": true,
"bin": {
"vue-demi-fix": "bin/vue-demi-fix.js",
"vue-demi-switch": "bin/vue-demi-switch.js"
},
"engines": {
"node": ">=12"
},
"peerDependencies": {
"@vue/composition-api": "^1.0.0-rc.1",
"vue": "^3.0.0-0 || ^2.6.0"
},
"peerDependenciesMeta": {
"@vue/composition-api": {
"optional": true
}
}
},
"node_modules/pinia/node_modules/vue-demi": { "node_modules/pinia/node_modules/vue-demi": {
"version": "0.13.1", "version": "0.13.1",
"resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.13.1.tgz", "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.13.1.tgz",
@ -13893,6 +13940,11 @@
} }
} }
}, },
"animate.css": {
"version": "4.1.1",
"resolved": "https://registry.npmmirror.com/animate.css/-/animate.css-4.1.1.tgz",
"integrity": "sha512-+mRmCTv6SbCmtYJCN4faJMNFVNN5EuCTTprDTAo7YzIGji2KADmakjVA3+8mVDkZ2Bf09vayB35lSQIex2+QaQ=="
},
"ansi-colors": { "ansi-colors": {
"version": "4.1.1", "version": "4.1.1",
"resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz",
@ -18456,6 +18508,22 @@
} }
} }
}, },
"pinia-plugin-persist": {
"version": "1.0.0",
"resolved": "https://registry.npmmirror.com/pinia-plugin-persist/-/pinia-plugin-persist-1.0.0.tgz",
"integrity": "sha512-M4hBBd8fz/GgNmUPaaUsC29y1M09lqbXrMAHcusVoU8xlQi1TqgkWnnhvMikZwr7Le/hVyMx8KUcumGGrR6GVw==",
"requires": {
"vue-demi": "^0.12.1"
},
"dependencies": {
"vue-demi": {
"version": "0.12.5",
"resolved": "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.12.5.tgz",
"integrity": "sha512-BREuTgTYlUr0zw0EZn3hnhC3I6gPWv+Kwh4MCih6QcAeaTlaIX0DwOVN0wHej7hSvDPecz4jygy/idsgKfW58Q==",
"requires": {}
}
}
},
"platform": { "platform": {
"version": "1.3.6", "version": "1.3.6",
"resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz", "resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz",

View File

@ -13,6 +13,7 @@
"@vicons/antd": "^0.10.0", "@vicons/antd": "^0.10.0",
"@vicons/ionicons5": "^0.10.0", "@vicons/ionicons5": "^0.10.0",
"ali-oss": "^6.17.1", "ali-oss": "^6.17.1",
"animate.css": "^4.1.1",
"axios": "^0.26.1", "axios": "^0.26.1",
"dayjs": "^1.11.2", "dayjs": "^1.11.2",
"mockjs": "^1.1.0", "mockjs": "^1.1.0",

View File

@ -31,7 +31,6 @@ class Earth {
// contextOptions: { // contextOptions: {
// requestWebgl1: true // 指定上下文使用webgl1的上下文 // requestWebgl1: true // 指定上下文使用webgl1的上下文
// }, // },
selectionIndicator: false // 去除绿色选择框 selectionIndicator: false // 去除绿色选择框
}) })
viewer._cesiumWidget._creditContainer.style.display = 'none' viewer._cesiumWidget._creditContainer.style.display = 'none'

View File

@ -7,11 +7,12 @@
// } // }
// } // }
// export default layerManager // export default layerManager
import { TDT_TOKEN } from '@/components/earth/tokens.js'
class LayerManager { class LayerManager {
constructor(viewer) { constructor(viewer) {
this.viewer = viewer this.viewer = viewer
this.tilesetList = [] this.tilesetList = []
this.baseLayer = null
} }
async add3DTilesetByUrl(url, name) { async add3DTilesetByUrl(url, name) {
@ -56,6 +57,40 @@ class LayerManager {
}) })
}) })
} }
loadBaseLayerByType(option) {
const type = option.code
const imgProvider = new Cesium.WebMapTileServiceImageryProvider({
url: `http://{s}.tianditu.com/${type}_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=${type}&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles&tk=${TDT_TOKEN}`,
subdomains: ['t0', 't1', 't2', 't3', 't4', 't5', 't6', 't7'],
layer: `${type}`,
style: 'default',
format: 'image/jpeg',
tileMatrixSetID: 'GoogleMapsCompatible',
maximumLevel: 18,
show: true
})
const baseLayer = viewer.imageryLayers.addImageryProvider(imgProvider)
if (type !== 'cva') {
this.baseLayer = {
name: option.name,
layer: baseLayer
}
} else {
this.annotationLayer = {
name: option.name,
layer: baseLayer
}
}
return baseLayer
}
removeLayer(layer) {
if (layer) {
viewer.imageryLayers.remove(layer)
}
}
} }
export default LayerManager export default LayerManager

View File

@ -0,0 +1,3 @@
export const CESIUM_TOKEN = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJkZWJjOTRmOS04ZWVlLTQ2Y2QtYjk1Zi1mMTlhYTI5YjRjZGQiLCJpZCI6Njg1MDEsImlhdCI6MTYzMjc5Nzk5NX0.Y - SNJskkiSEYtqKERD6sib6lYKQuzXf_z_z3mBVpEjI'
export const TDT_TOKEN = 'b48998cf12f83e0215989b14acf59e3f'

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="baseMapManager"> <div class="baseMapManager" @mouseleave="showOptions(false)">
<!-- <n-modal v-model:show="isOptionShow"> <transition name="move" enter-active-class="animate__animated animate__fadeInRight" leave-active-class="animate__animated animate__fadeOutRight">
<div v-show="isOptionShow" class="options"> <div v-show="isOptionShow" class="options ">
<div v-for="(option,index) in options" :key="index" class="option" @click="handleCheck(option)"> <div v-for="(option,index) in options" :key="index" class="option" @click="handleCheck(option)">
<img :src="option.imgUrl" alt=""> <img :src="option.imgUrl" alt="">
<div class="title"> <div class="title">
@ -9,14 +9,10 @@
</div> </div>
</div> </div>
</div> </div>
</n-modal> --> </transition>
<div v-show="isOptionShow" class="options" @mouseleave="showOptions(false)">
<div v-for="(option,index) in options" :key="index" class="option" @click="handleCheck(option)"> <div class="annotation">
<img :src="option.imgUrl" alt=""> <n-checkbox size="large" label="注记" @update:checked="handleCheckedChange" />
<div class="title">
{{ option.name }}
</div>
</div>
</div> </div>
<div class="checked option" @click="showOptions(true)"> <div class="checked option" @click="showOptions(true)">
<img :src="checked.imgUrl" alt=""> <img :src="checked.imgUrl" alt="">
@ -31,7 +27,7 @@
<script setup > <script setup >
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
import { ref, reactive, toRefs, watch, onMounted, getCurrentInstance } from 'vue' import { ref, reactive, toRefs, watch, onMounted, getCurrentInstance } from 'vue'
import LayeManager from '@/components/earth/layerManager/layerManager.js'
// const emit = defineEmits([""]) // const emit = defineEmits([""])
// const props = defineProps({ // const props = defineProps({
// propData: { // propData: {
@ -61,6 +57,25 @@ function handleCheck(obj) {
checked.value = obj checked.value = obj
isOptionShow.value = false isOptionShow.value = false
} }
const layeManager = new LayeManager(window.viewer)
let annotationLayer
function handleCheckedChange(checked) {
if (checked) {
annotationLayer = layeManager.loadBaseLayerByType({ name: '注记', code: 'cva' })
} else {
layeManager.removeLayer(annotationLayer)
}
}
watch(() => checked.value, newV => {
if (layeManager.baseLayer?.layer) {
layeManager.removeLayer(layeManager.baseLayer.layer)
}
layeManager.loadBaseLayerByType(newV)
if (annotationLayer) {
viewer.imageryLayers.raiseToTop(annotationLayer)
}
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.baseMapManager{ .baseMapManager{
@ -74,6 +89,15 @@ function handleCheck(obj) {
.checked{ .checked{
border: 1px solid rgb(74,131,247); border: 1px solid rgb(74,131,247);
} }
.annotation{
position: absolute;
right: 0;
bottom: 100px;
background: rgba(0,0,0,0.1);
width: 80px;
text-align: center;
color: white;
}
} }
.option{ .option{
width: 120px; width: 120px;
@ -97,4 +121,5 @@ function handleCheck(obj) {
width: 30px; width: 30px;
} }
} }
</style> </style>

View File

@ -1,6 +1,7 @@
<template> <template>
<div> <div>
<baseMapManager class="baseMap" /> <baseMapManager class="baseMap" />
<map-tools class="mapTools" />
</div> </div>
</template> </template>
@ -8,6 +9,7 @@
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
import { ref, reactive, toRefs, watch, onMounted, getCurrentInstance } from 'vue' import { ref, reactive, toRefs, watch, onMounted, getCurrentInstance } from 'vue'
import baseMapManager from '@/components/mapUI/baseMapManager/baseMapManager.vue' import baseMapManager from '@/components/mapUI/baseMapManager/baseMapManager.vue'
import mapTools from './mapTools/mapTools.vue'
// const emit = defineEmits([""]) // const emit = defineEmits([""])
// const props = defineProps({ // const props = defineProps({
@ -25,4 +27,9 @@ import baseMapManager from '@/components/mapUI/baseMapManager/baseMapManager.vue
bottom: 20px; bottom: 20px;
right: 10px; right: 10px;
} }
.mapTools{
position: fixed;
bottom: 200px;
right: 30px;
}
</style> </style>

View File

@ -0,0 +1,27 @@
<template>
<div class="mapTools">
mapTools
</div>
</template>
<script setup >
// eslint-disable-next-line no-unused-vars
import { ref, reactive, toRefs, watch, onMounted, getCurrentInstance } from 'vue'
// const emit = defineEmits([""])
// const props = defineProps({
// propData: {
// type: String,
// default: ''
// },
// })
// const { } = toRefs(props);
</script>
<style lang="scss" scoped>
.mapTools{
width: 50px;
height: 400px;
background: white;
}
</style>

View File

@ -1,6 +1,6 @@
import '@/styles/index.scss' import '@/styles/index.scss'
import 'uno.css' import 'uno.css'
import 'animate.css/animate.min.css'
import { createApp } from 'vue' import { createApp } from 'vue'
import { setupRouter } from '@/router' import { setupRouter } from '@/router'
import { setupStore } from '@/store' import { setupStore } from '@/store'