| | |
| | | /* eslint-disable camelcase */ |
| | | <template> |
| | | <div id="viewer-container" |
| | | style="height: 100%; width: 100%;"> |
| | | style="height: 100%; width: 100%;" |
| | | @click="mapClick($event)"> |
| | | |
| | | <dimension /> |
| | | |
| | | <left-nav ref="leftNav"></left-nav> |
| | | |
| | | <mapPopup /> |
| | | |
| | | <campusBuildingSearch ref="campusBuildingSearch" /> |
| | | |
| | | <campusNav ref="campusNavRoute" |
| | | v-show="campusNavFlag" /> |
| | | |
| | | <org-nav-bar v-if="orgNavBarFlag"></org-nav-bar> |
| | | <arc-nav-bar v-if="arcNavBarFlag"></arc-nav-bar> |
| | | </div> |
| | | </template> |
| | | <script> |
| | | |
| | | import { mapGetters } from 'vuex' |
| | | import mapPopup from './component/mapPopup.vue' |
| | | import mapPopup from './components/mapPopup.vue' |
| | | import campusBuildingSearch from './components/campusBuildingSearch.vue' |
| | | import dimension from './components/dimension.vue' |
| | | |
| | | export default { |
| | | name: 'mapBox', |
| | | components: { |
| | | mapPopup |
| | | mapPopup, |
| | | campusBuildingSearch, |
| | | dimension |
| | | }, |
| | | data () { |
| | | return { |
| | |
| | | // 详情弹框显示关闭 |
| | | 'detailsPopup', |
| | | // 全景弹框显示关闭 |
| | | 'panoramaPopup' |
| | | 'panoramaPopup', |
| | | // 校内导航的显示关闭 |
| | | 'campusNavFlag', |
| | | 'orgNavBarFlag', |
| | | 'arcNavBarFlag' |
| | | ]) |
| | | }, |
| | | mounted () { |
| | |
| | | viewer.measure.deactivate() |
| | | } |
| | | |
| | | function gotoModel () { |
| | | viewer.flyTo(tileset) |
| | | } |
| | | |
| | | function initViewer () { |
| | | viewer = new that.DC.Viewer('viewer-container', { |
| | | contextOptions: { |
| | |
| | | |
| | | that.$store.commit('SET_VIEWER', viewer) |
| | | |
| | | viewer.on(that.DC.SceneEventType.CAMERA_CHANGED, (e) => { |
| | | const height = Math.ceil(viewer.camera.positionCartographic.height) |
| | | |
| | | if (height < 100) { |
| | | viewer.camera.setView({ |
| | | destination: that.DC.Namespace.Cesium.Cartesian3.fromRadians(viewer.camera.positionCartographic.longitude, viewer.camera.positionCartographic.latitude, 100), |
| | | orientation: { |
| | | // 指向 |
| | | heading: that.DC.Namespace.Cesium.Math.toRadians(0, 0), |
| | | // 视角 |
| | | pitch: that.DC.Namespace.Cesium.Math.toRadians(-90), |
| | | roll: 0.0 |
| | | } |
| | | }) |
| | | }; |
| | | if (height > 600000) { |
| | | viewer.camera.setView({ |
| | | destination: that.DC.Namespace.Cesium.Cartesian3.fromRadians(viewer.camera.positionCartographic.longitude, viewer.camera.positionCartographic.latitude, 600000), |
| | | orientation: { |
| | | // 指向 |
| | | heading: that.DC.Namespace.Cesium.Math.toRadians(0, 0), |
| | | // 视角 |
| | | pitch: that.DC.Namespace.Cesium.Math.toRadians(-90), |
| | | roll: 0.0 |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | // 最小 |
| | | viewer.scene.screenSpaceCameraController.minimumZoomDistance = 500 |
| | | // 最大 |
| | | viewer.scene.screenSpaceCameraController.maximumZoomDistance = 600000 |
| | | // 设置相机缩小时的速率 |
| | | viewer.scene.screenSpaceCameraController._minimumZoomRate = 30000 |
| | | // 设置相机放大时的速率 |
| | | viewer.scene.screenSpaceCameraController._maximumZoomRate = 5906376272000 |
| | | // 视角平移 |
| | | viewer.scene.screenSpaceCameraController.enableRotate = true |
| | | // 视角缩放 |
| | | viewer.scene.screenSpaceCameraController.enableZoom = true |
| | | // 视角旋转 |
| | | viewer.scene.screenSpaceCameraController.enableTilt = false |
| | | |
| | | that.$refs.leftNav.initialize(viewer) |
| | | |
| | | const popup = viewer.popup |
| | | // const baselayer = that.DC.ImageryLayerFactory.createImageryLayer(that.DC.ImageryType.XYZ, { |
| | | // url: 'https://webmap-tile.sf-express.com/MapTileService/rt?x={col}&y={row}&z={level}' |
| | | // // url: 'https://webmap-tile.sf-express.com/MapTileService/rt?fetchtype=static&x={x}&y={y}&z={z}&project=sfmap&pic_size=256&pic_type=png8&data_name=361100&data_format=merged-dat&data_type=normal' // 行政区划 |
| | | |
| | | popup.hide() |
| | | // }) |
| | | |
| | | const baselayer = that.DC.ImageryLayerFactory.createArcGisImageryLayer({ |
| | | url: |
| | | 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer' |
| | | const baselayer = that.DC.ImageryLayerFactory.createAmapImageryLayer( |
| | | { |
| | | crs: 'WGS84' |
| | | } |
| | | ) |
| | | |
| | | const arcgisLayer = that.DC.ImageryLayerFactory.createArcGisImageryLayer({ |
| | | url: 'http://59.55.128.156:6080/arcgis/rest/services/fzhl/MapServer' |
| | | }) |
| | | |
| | | viewer.addBaseLayer(baselayer, { |
| | | iconUrl: 'examples/images/icon/img.png', |
| | | name: '影像' |
| | | }) |
| | | |
| | | // eslint-disable-next-line camelcase |
| | | const baselayer_shaded = that.DC.ImageryLayerFactory.createArcGisImageryLayer({ |
| | | url: |
| | | 'http://services.arcgisonline.com/arcgis/rest/services/World_Shaded_Relief/MapServer' |
| | | }) |
| | | viewer.addBaseLayer(baselayer_shaded, { |
| | | iconUrl: 'examples/images/icon/elec.png', |
| | | name: '电子' |
| | | }) |
| | | viewer.imageryLayers.addImageryProvider(arcgisLayer) |
| | | |
| | | // viewer.addBaseLayer(baselayer, { |
| | | // iconUrl: 'examples/images/icon/img.png', |
| | | // name: '影像' |
| | | // }) |
| | | |
| | | // viewer.addBaseLayer(wmtslayer, { |
| | | // iconUrl: 'examples/images/icon/img.png', |
| | | // name: '影像' |
| | | // }) |
| | | |
| | | // // eslint-disable-next-line camelcase |
| | | // const baselayer_shaded = that.DC.ImageryLayerFactory.createArcGisImageryLayer({ |
| | | // url: |
| | | // 'http://services.arcgisonline.com/arcgis/rest/services/World_Shaded_Relief/MapServer' |
| | | // }) |
| | | // viewer.addBaseLayer(baselayer_shaded, { |
| | | // iconUrl: 'examples/images/icon/elec.png', |
| | | // name: '电子' |
| | | // }) |
| | | |
| | | // // eslint-disable-next-line camelcase |
| | | // const baselayer_street = that.DC.ImageryLayerFactory.createArcGisImageryLayer({ |
| | |
| | | // name: '地形' |
| | | // }) |
| | | |
| | | // const tilesetLayer = new that.DC.TilesetLayer('tilesetLayer') |
| | | // viewer.addLayer(tilesetLayer) |
| | | // const tileset = new that.DC.Tileset( |
| | | // 'http://resource.dvgis.cn/data/3dtiles/ljz/tileset.json' |
| | | // ) |
| | | // const style = new that.DC.TilesetStyle() |
| | | // style.color = { |
| | | // conditions: [ |
| | | // // eslint-disable-next-line no-template-curly-in-string |
| | | // ['${Height} >= 300', 'rgba(45, 0, 75, 0.5)'], |
| | | // // eslint-disable-next-line no-template-curly-in-string |
| | | // ['${Height} >= 200', 'rgb(102, 71, 151)'], |
| | | // // eslint-disable-next-line no-template-curly-in-string |
| | | // ['${Height} >= 100', 'rgb(170, 162, 204)'], |
| | | // // eslint-disable-next-line no-template-curly-in-string |
| | | // ['${Height} >= 50', 'rgb(224, 226, 238)'], |
| | | // // eslint-disable-next-line no-template-curly-in-string |
| | | // ['${Height} >= 25', 'rgb(252, 230, 200)'], |
| | | // // eslint-disable-next-line no-template-curly-in-string |
| | | // ['${Height} >= 10', 'rgb(248, 176, 87)'], |
| | | // // eslint-disable-next-line no-template-curly-in-string |
| | | // ['${Height} >= 5', 'rgb(198, 106, 11)'], |
| | | // // eslint-disable-next-line no-template-curly-in-string |
| | | // ['true', 'rgb(127, 59, 8)'] |
| | | // ] |
| | | // } |
| | | // tileset.setStyle(style) |
| | | // tilesetLayer.addOverlay(tileset) |
| | | // viewer.flyTo(tileset) |
| | | // tileset.on(that.DC.MouseEventType.CLICK, e => { |
| | | // // that.popupFlag = true |
| | | // viewer.use(new that.DC.Measure()) |
| | | |
| | | // viewer.scene.globe.depthTestAgainstTerrain = false |
| | | |
| | | // // 定制化窗体 |
| | | // // eslint-disable-next-line no-unused-vars |
| | | // var popup = new that.DC.DivForms(that.viewer, { |
| | | // domId: 'divFormsDomBox', |
| | | // position: [ |
| | | // e.position |
| | | // ] |
| | | // }) |
| | | |
| | | // that.$store.commit('SET_PANORAMAPOPUP', false) |
| | | // that.$store.commit('SET_DETAILSPOPUP', true) |
| | | // }) |
| | | |
| | | const wallLayer = new that.DC.VectorLayer('wallLayer') |
| | | viewer.addLayer(wallLayer) |
| | | |
| | | var arr = [ |
| | | [115.87597219, 28.74628526, 100], |
| | | [115.87556558, 28.74415792, 100], |
| | | [115.87459782, 28.74197687, 100], |
| | | [115.87371834, 28.74219927, 100], |
| | | [115.87210924, 28.74182217, 100], |
| | | [115.86469971, 28.73630725, 100], |
| | | [115.86387107, 28.73620123, 100], |
| | | [115.86274498, 28.73616026, 100], |
| | | [115.86173699, 28.74241350, 100], |
| | | [115.86105468, 28.74643934, 100], |
| | | [115.86609240, 28.74642593, 100], |
| | | [115.87597219, 28.74628526, 100] |
| | | ] |
| | | |
| | | arr.forEach(item => { |
| | | item = item.join(',') |
| | | }) |
| | | |
| | | arr = arr.join(';') |
| | | |
| | | const wall = new that.DC.Wall( |
| | | arr |
| | | ) |
| | | wall.setStyle({ |
| | | material: new that.DC.WallTrailMaterialProperty({ |
| | | color: that.DC.Color.DEEPSKYBLUE, |
| | | speed: 4 |
| | | }) |
| | | }) |
| | | wallLayer.addOverlay(wall) |
| | | |
| | | viewer.use(new that.DC.Measure()) |
| | | |
| | | viewer.flyTo(wallLayer) |
| | | |
| | | // viewer.zoomToPosition( |
| | | // new that.DC.Position(115.87186406, 28.74449337, 1200, 0, -90) |
| | | // viewer.flyToPosition( |
| | | // new that.DC.Position(117.08489820, 31.65413916, 1500, 0, -90, 45) |
| | | // ) |
| | | |
| | | viewer.compass.enable = true |
| | | viewer.zoomController.enable = true |
| | | viewer.locationBar.enable = true |
| | | viewer.distanceLegend.enable = true |
| | | viewer.hawkeyeMap.enable = true |
| | | viewer.hawkeyeMap.addBaseLayer( |
| | | that.DC.ImageryLayerFactory.createAmapImageryLayer( |
| | | { |
| | | crs: 'WGS84' |
| | | } |
| | | ) |
| | | ) |
| | | // viewer.distanceLegend.enable = true |
| | | } |
| | | |
| | | that.DC.ready(initViewer) |
| | | }, |
| | | methods: { |
| | | |
| | | mapClick (e) { |
| | | this.$refs.campusBuildingSearch.shortcutShow(e) |
| | | } |
| | | } |
| | | } |
| | | </script> |