智慧园区前端大屏
shuishen
2024-11-22 5c41d0cc9b7cc665b3136e5cdfdfc3b7ccd6cc3b
倾斜模型加载调整
4 files modified
132 ■■■■■ changed files
src/hooks/initMap.js 19 ●●●● patch | view | raw | blame | history
src/pages/layout/components/scomponents/cesium/AmapMercatorTilingScheme/index.js 4 ●●●● patch | view | raw | blame | history
src/pages/layout/components/scomponents/layersControl.vue 97 ●●●●● patch | view | raw | blame | history
src/router/index.js 12 ●●●● patch | view | raw | blame | history
src/hooks/initMap.js
@@ -2,25 +2,25 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2024-10-25 15:09:55
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2024-11-13 16:37:17
 * @LastEditTime: 2024-11-22 14:54:14
 * @FilePath: \bigScreen\src\hooks\initMap.js
 * @Description: 
 * 
 * Copyright (c) 2024 by shuishen, All Rights Reserved. 
 */
let viewer = null
window.$viewer = null
const { VITE_APP_BASE } = import.meta.env
import { useMap } from 'store/map'
import { nextTick, onMounted, onUnmounted } from 'vue'
import * as turf from '@turf/turf'
import * as Cesium from 'cesium'
import 'cesium/Build/Cesium/Widgets/widgets.css'
// import * as Cesium from 'cesium'
// import 'cesium/Build/Cesium/Widgets/widgets.css'
export function readyViewer () {
  const store = useMap()
  function initMap () {
    if (viewer) return
    if (window.$viewer) return
    nextTick(() => {
      DC.ready({
@@ -29,9 +29,8 @@
        turf,
      }).then(() => {
        viewer = new DC.Viewer('viewer-container')
        viewer.locationBar.enable = true
        window.$viewer = viewer
        window.$viewer = new DC.Viewer('viewer-container')
        window.$viewer.locationBar.enable = true
        window.$viewer.zoomToPosition(new DC.Position(
          115.1048036679409,
@@ -52,8 +51,8 @@
  })
  onUnmounted(() => {
    viewer.destroy()
    viewer = null
    window.$viewer.destroy()
    window.$viewer = null
    delete window.$viewer
    store.setLoadMap(false)
  })
src/pages/layout/components/scomponents/cesium/AmapMercatorTilingScheme/index.js
@@ -2,8 +2,8 @@
 * @Author: GuLiMmo 2820890765@qq.com
 * @Date: 2024-05-11 09:18:29
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2024-10-28 20:14:09
 * @FilePath: \bigScreen\src\views\layout\components\scomponents\cesium\AmapMercatorTilingScheme\index.js
 * @LastEditTime: 2024-11-21 18:17:18
 * @FilePath: \bigScreen\src\pages\layout\components\scomponents\cesium\AmapMercatorTilingScheme\index.js
 * @Description: 高德地图纠偏
 * Copyright (c) 2024 by GuLiMmo, All Rights Reserved.
 */
src/pages/layout/components/scomponents/layersControl.vue
@@ -2,7 +2,7 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2024-10-31 10:47:29
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2024-11-19 15:53:37
 * @LastEditTime: 2024-11-22 14:52:56
 * @FilePath: \bigScreen\src\pages\layout\components\scomponents\layersControl.vue
 * @Description:
 *
@@ -78,6 +78,9 @@
const treeRef = ref(null)
const Cesium = DC.getLib('Cesium')
console.log(Cesium, 45646465)
const treeProps = {
  indent: 16,
  showLabelLine: true,
@@ -551,9 +554,9 @@
  }
}
let addTileLayers = {}
let tileLayers = new DC.TilesetLayer('tileLayers')
window.$viewer.addLayer(tileLayers)
window.addTileLayers = {}
window.tileLayers = new DC.TilesetLayer('tileLayers')
window.$viewer.addLayer(window.tileLayers)
const handleCheckChange = (data) => {
  let options = treeRef.value?.getCheckedNodes()
@@ -565,22 +568,41 @@
      //  const Cesium  = DC
      if (item.subType == '3Dtile') {
        if (!addTileLayers[item.layerName]) {
          addTileLayers[item.layerName] = item.urlData.map(i => {
            let tile = new DC.Tileset(i.url)
        if (!window.addTileLayers[item.layerName]) {
          // window.addTileLayers[item.layerName] = []
          // let tile = window.$viewer.delegate.scene.primitives.add(new Cesium.Cesium3DTileset({
          //   url: '/zhyq/mx/tile_01/tileset.json',
          // }))
            tileLayers.addOverlay(tile)
          // console.log(tile, new Cesium.Cesium3DTileset({
          //   url: '/zhyq/mx/tile_01/tileset.json',
          // }), 121323)
          // item.urlData.forEach(i => {
          // })
          window.addTileLayers[item.layerName] = item.urlData.map(i => {
            let tile = new DC.Tileset(i.url, {
              maximumMemoryUsage: 1024 * 1024 * 1024,
              maximumScreenSpaceError: 48,
              skipLevels: 5,
              skipLevelOfDetail: true,
              skipScreenSpaceErrorFactor: 128
            })
            window.tileLayers.addOverlay(tile)
            return tile
          })
        } else {
          addTileLayers[item.layerName].forEach(i => i.show = true)
          window.addTileLayers[item.layerName].forEach(i => i.show = true)
        }
        window.$viewer.flyTo(addTileLayers[item.layerName][0])
        // window.$viewer.flyTo(window.addTileLayers[item.layerName][0])
      } else if (item.subType == 'labelPoint') {
        if (!addTileLayers[item.layerName]) {
          addTileLayers[item.layerName] = new DC.HtmlLayer(item.layerName)
          window.$viewer.addLayer(addTileLayers[item.layerName])
        if (!window.addTileLayers[item.layerName]) {
          window.addTileLayers[item.layerName] = new DC.HtmlLayer(item.layerName)
          window.$viewer.addLayer(window.addTileLayers[item.layerName])
          item.method(item.params).then(res => {
            let data = res.data.data.records
@@ -619,16 +641,16 @@
              divIcon.on(DC.MouseEventType.CLICK, incident)
              addTileLayers[item.layerName].addOverlay(divIcon)
              window.addTileLayers[item.layerName].addOverlay(divIcon)
            })
          })
        } else {
          addTileLayers[item.layerName].show = true
          window.addTileLayers[item.layerName].show = true
        }
      } else if (item.subType == 'geojsonWall') {
        if (!addTileLayers[item.layerName]) {
          addTileLayers[item.layerName] = new DC.VectorLayer(item.layerName)
          window.$viewer.addLayer(addTileLayers[item.layerName])
        if (!window.addTileLayers[item.layerName]) {
          window.addTileLayers[item.layerName] = new DC.VectorLayer(item.layerName)
          window.$viewer.addLayer(window.addTileLayers[item.layerName])
          item.source.features.forEach(i => {
            let wall = new DC.Wall(
@@ -641,17 +663,17 @@
                speed: 10
              })
            })
            addTileLayers[item.layerName].addOverlay(wall)
            window.addTileLayers[item.layerName].addOverlay(wall)
          })
        } else {
          addTileLayers[item.layerName].show = true
          window.addTileLayers[item.layerName].show = true
        }
      } else if (item.subType == 'geojsonPipe') {
        if (!addTileLayers[item.layerName]) {
          addTileLayers[item.layerName] = new DC.VectorLayer(item.layerName)
          window.$viewer.addLayer(addTileLayers[item.layerName])
        if (!window.addTileLayers[item.layerName]) {
          window.addTileLayers[item.layerName] = new DC.VectorLayer(item.layerName)
          window.$viewer.addLayer(window.addTileLayers[item.layerName])
          function computeCircle(radius) {
          function computeCircle (radius) {
            var positions = []
            for (var i = 0; i < 360; i++) {
              var radians = DC.Math.toRadians(i)
@@ -672,29 +694,29 @@
            polylineVolume.setStyle({
              material: item.color
            })
            addTileLayers[item.layerName].addOverlay(polylineVolume)
            window.addTileLayers[item.layerName].addOverlay(polylineVolume)
          })
        } else {
          addTileLayers[item.layerName].show = true
          window.addTileLayers[item.layerName].show = true
        }
      }
    } else {
      if (addTileLayers[item.layerName]) {
      if (window.addTileLayers[item.layerName]) {
        if (item.subType == '3Dtile') {
          addTileLayers[item.layerName].forEach(i => i.show = false)
          window.addTileLayers[item.layerName].forEach(i => i.show = false)
        } else if (item.subType == 'labelPoint') {
          addTileLayers[item.layerName].show = false
          window.addTileLayers[item.layerName].show = false
        } else if (item.subType == 'geojsonWall') {
          addTileLayers[item.layerName].show = false
          window.addTileLayers[item.layerName].show = false
        } else if (item.subType == 'geojsonPipe') {
          addTileLayers[item.layerName].show = false
          window.addTileLayers[item.layerName].show = false
        }
      }
    }
  })
}
function findObjectById(data, id) {
function findObjectById (data, id) {
  // 遍历数据数组
  for (let i = 0; i < data.length; i++) {
    const item = data[i]
@@ -753,7 +775,7 @@
// });
// 销毁
function destroy() {
function destroy () {
  let arr = Object.keys(addPupoLayers)
  arr.filter(i => i != 'hgyq').forEach(i => {
    addPupoLayers[i] && window.$viewer.removeLayer(addPupoLayers[i])
@@ -762,10 +784,11 @@
}
onUnmounted(() => {
  tileLayers && window.$viewer.removeLayer(tileLayers)
  let arr = Object.keys(addTileLayers)
  window.tileLayers && window.$viewer.removeLayer(window.tileLayers)
  delete window.tileLayers
  let arr = Object.keys(window.addTileLayers)
  arr.filter(i => i != 'hgyq').forEach(i => {
    addTileLayers[i] && window.$viewer.removeLayer(addTileLayers[i])
    addTileLwindow.addTileLayersayers[i] && window.$viewer.removeLayer(window.addTileLayers[i])
  })
  // 弹窗销毁
  destroy()
src/router/index.js
@@ -2,7 +2,7 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2024-10-25 16:35:31
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2024-11-21 15:35:48
 * @LastEditTime: 2024-11-21 15:44:21
 * @FilePath: \bigScreen\src\router\index.js
 * @Description: 
 * 
@@ -14,11 +14,11 @@
const subLayout = () => import('@/pages/sub/index.vue')
const companyInfo = () => import('@/views/companyInfo/index.vue')
const routes = [
  {
    path: '/:catchAll(.*)',
    name: 'not-found',
    redirect: '/layout',
  },
  // {
  //   path: '/:catchAll(.*)',
  //   name: 'not-found',
  //   redirect: '/layout',
  // },
  {
    path: '',
    redirect: '/layout',