/* eslint-disable camelcase */
|
<template>
|
<div id="viewer-container"
|
style="height: 100%; width: 100%;">
|
|
<left-nav ref="leftNav"></left-nav>
|
|
<mapPopup />
|
</div>
|
</template>
|
<script>
|
|
import { mapGetters } from 'vuex'
|
import mapPopup from './component/mapPopup.vue'
|
|
export default {
|
name: 'mapBox',
|
components: {
|
mapPopup
|
},
|
data () {
|
return {
|
DC: null
|
}
|
},
|
computed: {
|
...mapGetters([
|
'viewer',
|
'popupBgUrl',
|
'pupupQRUrl',
|
// 终点
|
'terminus',
|
// 起点
|
'startingPoint',
|
// 点信息
|
'pointPosition',
|
// 点名称
|
'stateName',
|
// 地址
|
'siteName',
|
// 介绍
|
'introduceText',
|
// 全景地址
|
'panoramaUrl',
|
// 详情弹框显示关闭
|
'detailsPopup',
|
// 全景弹框显示关闭
|
'panoramaPopup'
|
])
|
},
|
mounted () {
|
var that = this
|
|
let viewer
|
|
that.DC = global.DC
|
|
function distanceSurface () {
|
viewer.measure.distanceSurface()
|
}
|
|
function calcArea () {
|
viewer.measure.area()
|
}
|
|
function areaSurface () {
|
viewer.measure.areaSurface()
|
}
|
|
function calcAngle () {
|
viewer.measure.angle()
|
}
|
|
function calcModelAngle () {
|
viewer.measure.angle({
|
clampToModel: true
|
})
|
}
|
|
function calcHeight () {
|
viewer.measure.height()
|
}
|
|
function calcModelHeight () {
|
viewer.measure.height({
|
clampToModel: true
|
})
|
}
|
|
function calcHeading () {
|
viewer.measure.heading()
|
}
|
|
function areaHeight () {
|
viewer.measure.areaHeight()
|
}
|
|
function calcTriangleHeight () {
|
viewer.measure.triangleHeight()
|
}
|
|
function calcModelTriangleHeight () {
|
viewer.measure.triangleHeight({
|
clampToModel: true
|
})
|
}
|
|
function deactivate () {
|
viewer.measure.deactivate()
|
}
|
|
function gotoModel () {
|
viewer.flyTo(tileset)
|
}
|
|
function initViewer () {
|
viewer = new that.DC.Viewer('viewer-container', {
|
contextOptions: {
|
webgl: {
|
stencil: true,
|
preserveDrawingBuffer: true
|
}
|
}
|
})
|
|
that.$store.commit('SET_VIEWER', viewer)
|
|
that.$refs.leftNav.initialize(viewer)
|
|
const popup = viewer.popup
|
|
popup.hide()
|
|
const baselayer = that.DC.ImageryLayerFactory.createArcGisImageryLayer({
|
url:
|
'http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/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: '电子'
|
})
|
|
// eslint-disable-next-line camelcase
|
const baselayer_street = that.DC.ImageryLayerFactory.createArcGisImageryLayer({
|
url:
|
'http://services.arcgisonline.com/arcgis/rest/services/World_Physical_Map/MapServer'
|
})
|
viewer.addBaseLayer(baselayer_street, {
|
iconUrl: 'examples/images/icon/ter.png',
|
name: '地形'
|
})
|
|
// eslint-disable-next-line camelcase
|
const baselayer_ter = that.DC.ImageryLayerFactory.createArcGisImageryLayer({
|
url:
|
'http://services.arcgisonline.com/arcgis/rest/services/World_Terrain_Base/MapServer'
|
})
|
viewer.addBaseLayer(baselayer_ter, {
|
iconUrl: 'examples/images/icon/ter.png',
|
name: '地形'
|
})
|
|
const layer = new that.DC.TilesetLayer('layer')
|
viewer.addLayer(layer)
|
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)']
|
]
|
}
|
|
viewer.use(new that.DC.Measure())
|
|
tileset.setStyle(style)
|
layer.addOverlay(tileset)
|
viewer.flyTo(tileset)
|
|
tileset.on(that.DC.MouseEventType.CLICK, e => {
|
// that.popupFlag = true
|
|
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)
|
})
|
|
// viewer.zoomToPosition(
|
// new DC.Position(105.565571, 31.984708, 15362816, 0, -90)
|
// )
|
|
viewer.compass.enable = true
|
viewer.zoomController.enable = true
|
viewer.locationBar.enable = true
|
viewer.distanceLegend.enable = true
|
}
|
|
that.DC.ready(initViewer)
|
},
|
methods: {
|
|
}
|
}
|
</script>
|
|
<style lang='scss' scope>
|
</style>
|