/* eslint-disable camelcase */
|
<template>
|
<div style="height: 100%; width: 100%; position: relative;">
|
<div v-show="SelectTimeFlag">
|
<div class="selectname_left">
|
<select-name ref="selectNameLeft" @selectItem="selectItemLeft" :value="currentTitle" :selectList="farmSelectList"></select-name>
|
</div>
|
<select-time
|
ref="leftRoller"
|
:leftOrRight="'left'"
|
class="l-time"
|
:selectList="leftRollerLayers"
|
></select-time>
|
</div>
|
|
<div v-show="SelectTimeFlag">
|
<div class="selectname_right">
|
<select-name ref="selectNameRight" @selectItem="selectItemRight" :selectList="farmSelectList" :value="currentTitle"></select-name>
|
</div>
|
<select-time
|
ref="rightRoller"
|
:leftOrRight="'right'"
|
class="r-time"
|
:selectList="rightRollerLayers"
|
></select-time>
|
</div>
|
|
<div class="location-box" v-show="!rollerCloseShow && !screenShow">
|
<el-input
|
placeholder="请输入地点/经纬度:113.25,30.53"
|
v-model="location"
|
class="input-with-select"
|
>
|
<el-button slot="append" @click="setLocation" icon="el-icon-search"></el-button>
|
</el-input>
|
|
<div class="selectname_index">
|
<select-name ref="selectName" :value="currentTitle" :selectList="farmSelectList" @selectItem="selectItem"></select-name>
|
</div>
|
|
</div>
|
|
<div class="tool-box">
|
<!-- <div class="measure" v-show="screenShow">
|
<div class="btn">
|
<span>
|
<i class="el-icon-time"></i>
|
</span>
|
标注
|
</div>
|
</div>-->
|
|
<div class="measure" v-show="!screenShow">
|
<div class="btn" @click="deactivate">
|
<span>
|
<i class="el-icon-time"></i>
|
</span>
|
清除
|
</div>
|
<div class="line"></div>
|
<div class="btn" @click="distanceSurface">
|
<span>
|
<i class="el-icon-copy-document"></i>
|
</span>
|
测距
|
</div>
|
<div class="line"></div>
|
<div class="btn" @click="areaSurface">
|
<span>
|
<i class="el-icon-menu"></i>
|
</span>
|
测面
|
</div>
|
</div>
|
|
<div v-show="!rollerCloseShow && !screenShow" class="func">
|
<div class="btn" style="color: #fff; background: #469CF3; height: 100%;">
|
<span>
|
<i class="el-icon-time"></i>
|
</span>
|
多时相
|
</div>
|
<div class="line"></div>
|
<div class="btn" @click="rollerShutters">
|
<span>
|
<i class="el-icon-copy-document"></i>
|
</span>
|
卷帘
|
</div>
|
<div class="line"></div>
|
<div class="btn" @click="splitScreen">
|
<span>
|
<i class="el-icon-menu"></i>
|
</span>
|
分屏
|
</div>
|
</div>
|
|
<div class="roller-close" @click="closeRollerShutters" v-show="rollerCloseShow"></div>
|
|
<div class="screen-close" @click="closeSplitScreen" v-show="screenShow"></div>
|
</div>
|
|
<div v-show="!screenShow" id="viewer-container" style="height: 100%; width: 100%"></div>
|
|
<split-screen v-if="screenShow"></split-screen>
|
|
<div
|
v-if="!rollerCloseShow && !screenShow"
|
style="position: fixed; top: auto; left: 0; right: 0; bottom: 44px; margin: auto; width: 610px; height: 68px;"
|
>
|
<time-line :timeLineList="timeLineList" :currentObj="currentObj" :currentInd="currentInd"></time-line>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
|
// import SelectName from '@/components/selectName'
|
import { getRemoteDetailsList,getFormat } from '@/assets/viewdata.js'
|
let baselayerElc = null
|
let num = 0
|
export default {
|
name: 'remote',
|
// components: { SelectName },
|
data () {
|
return {
|
// 左边集合
|
leftRollerLayers: [],
|
// 右边集合
|
rightRollerLayers: [],
|
SelectTimeFlag: false,
|
rollerCloseShow: false,
|
screenShow: false,
|
location: '',
|
// farmSelectList: viewdata,
|
// currentTitle: viewdata[0].name,
|
// timeLineList: viewdata[0].childItem,
|
// currentObj: viewdata[0].childItem[0],
|
farmSelectList: null,
|
currentTitle: null,
|
timeLineList: null,
|
currentObj: null,
|
currentInd: 0
|
}
|
},
|
created () {
|
this.settingViewdata()
|
},
|
mounted () {
|
if (global.viewer != null) {
|
global.viewer = null
|
}
|
var _this = this
|
function initViewer () {
|
global.viewer = new global.DC.Viewer('viewer-container', {
|
contextOptions: {
|
webgl: {
|
alpha: true,
|
stencil: true,
|
preserveDrawingBuffer: true
|
}
|
}
|
})
|
|
// 去除logo
|
const primitiveArr = global.viewer.scene.primitives._primitives
|
global.viewer.scene.primitives.remove(primitiveArr[0])
|
|
if (global.DC.Namespace.Cesium.FeatureDetection.supportsImageRenderingPixelated()) { // 判断是否支持图像渲染像素化处理
|
global.viewer.setOptions({
|
resolutionScale: window.devicePixelRatio
|
})
|
}
|
|
// 影像
|
global.viewer.imageryLayers.addImageryProvider(
|
new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({
|
url: 'http://t{s}.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=e45274b0235bb913eceb393aabbf9c9c',
|
subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
|
format: 'image/jpeg',
|
show: true,
|
maximumLevel: 18
|
})
|
)
|
|
|
|
global.viewer.use(new global.DC.Measure())
|
|
// _this.$nextTick(() => {
|
// if (viewdata.length > 0) {
|
// _this.settingViewdata()
|
// }
|
// });
|
|
// global.viewer.locationBar.enable = true
|
}
|
|
|
|
global.DC.ready(initViewer)
|
},
|
methods: {
|
goToDcBylatlon (lat, lon) {
|
global.viewer.camera.setView({
|
// Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
|
// fromDegrees()方法,将经纬度和高程转换为世界坐标
|
destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
|
lat, lon, 2800.0
|
),
|
orientation: {
|
// 指向
|
heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
|
// 视角
|
pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
|
roll: 0.0
|
}
|
})
|
},
|
deactivate () {
|
global.viewer.measure.deactivate()
|
},
|
// 遥感监测多时相基地下拉事件
|
selectItem (item, index) {
|
this.timeLineList = item.childItem
|
if(this.timeLineList.some(e=>{return e.type == "0"})){
|
for(var i = 0; i<this.timeLineList.length;i++){
|
if(this.timeLineList[i].type == "0"){
|
this.currentObj = this.timeLineList[i]
|
this.currentInd = i
|
break
|
}
|
}
|
}else{
|
this.currentObj = this.timeLineList[0]
|
this.currentInd = 0
|
}
|
this.goToDcBylatlon(item.latitude, item.longitude)
|
},
|
// 遥感监测卷帘左基地下拉事件
|
selectItemLeft (item, index) {
|
this.leftRollerLayers = item.childItem
|
this.rightRollerLayers = item.childItem
|
this.$refs.selectNameRight.currentTitle = item.name
|
this.$refs.leftRoller.init()
|
this.$refs.rightRoller.init()
|
this.goToDcBylatlon(item.latitude, item.longitude)
|
},
|
// 遥感监测卷帘右基地下拉事件
|
selectItemRight (item, index) {
|
this.leftRollerLayers = item.childItem
|
this.rightRollerLayers = item.childItem
|
this.$refs.selectNameLeft.currentTitle = item.name
|
this.$refs.rightRoller.init()
|
this.$refs.leftRoller.init()
|
this.goToDcBylatlon(item.latitude, item.longitude)
|
},
|
// 根据地址获取坐标
|
addrToGetCoordinate (addr) {
|
const that = this
|
this.$jsonp('https://apis.map.qq.com/ws/geocoder/v1/', {
|
key: '6POBZ-M3HK2-RMPU5-C6F4L-M3YTK-GTFVU',
|
output: 'jsonp',
|
address: addr
|
})
|
.then((res) => {
|
if (res.status === 0) {
|
// 用获取到的经纬度,修改地图的中心点
|
global.viewer.camera.flyTo({
|
// Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
|
// fromDegrees()方法,将经纬度和高程转换为世界坐标
|
destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
|
res.result.location.lng.toFixed(6), res.result.location.lat.toFixed(6), 1800.0
|
),
|
orientation: {
|
// 指向
|
heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
|
// 视角
|
pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
|
roll: 0.0
|
},
|
duration: 3,
|
complete () {
|
that.location = ''
|
}
|
})
|
} else {
|
that.$message(res.message)
|
that.location = ''
|
}
|
})
|
.catch((e) => {
|
that.$message(e)
|
})
|
},
|
|
setLocation () {
|
const longreg = /^(\-|\+)?(((\d|[1-9]\d|1[0-7]\d|0{1,3})\.\d{0,15})|(\d|[1-9]\d|1[0-7]\d|0{1,3})|180\.0{0,15}|180)$/
|
const latreg = /^(\-|\+)?([0-8]?\d{1}\.\d{0,15}|90\.0{0,15}|[0-8]?\d{1}|90)$/
|
const that = this
|
|
// 验证是否是中文
|
var pattern = new RegExp('[\u4E00-\u9FA5]+')
|
// 验证是否是英文
|
var pattern2 = new RegExp('[A-Za-z]+')
|
|
if (pattern.test(this.location) || pattern2.test(this.location)) {
|
this.addrToGetCoordinate(this.location)
|
return
|
}
|
|
if (this.location.indexOf(',') != -1 || this.location.indexOf(',') != -1) {
|
let arr
|
|
if (this.location.indexOf(',') != -1) {
|
arr = this.location.split(',')
|
} else {
|
arr = this.location.split(',')
|
}
|
|
if (arr.length > 2) {
|
this.$message('格式错误!')
|
} else {
|
if (!longreg.test(arr[0])) {
|
this.$message('经度整数部分为0-180,小数部分为0到15位!')
|
} else if (!latreg.test(arr[1])) {
|
this.$message('纬度整数部分为0-90,小数部分为0到15位!')
|
} else {
|
global.viewer.camera.flyTo({
|
// Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
|
// fromDegrees()方法,将经纬度和高程转换为世界坐标
|
destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
|
arr[0], arr[1], 1800.0
|
),
|
orientation: {
|
// 指向
|
heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
|
// 视角
|
pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
|
roll: 0.0
|
},
|
duration: 3,
|
complete () {
|
that.location = ''
|
}
|
})
|
}
|
}
|
} else {
|
this.$message('格式错误!')
|
}
|
},
|
|
splitScreen () {
|
this.screenShow = true
|
this.deactivate()
|
},
|
|
closeSplitScreen () {
|
this.screenShow = false
|
},
|
|
distanceSurface () {
|
global.viewer.measure.distanceSurface()
|
},
|
|
areaSurface () {
|
global.viewer.measure.areaSurface()
|
},
|
|
rollerShutters () {
|
if (num == 0) {
|
baselayerElc = global.DC.ImageryLayerFactory.createTdtImageryLayer({
|
key: 'e9533f5acb2ac470b07f406a4d24b4f0'
|
})
|
global.viewer.mapSplit.enable = true
|
} else {
|
global.viewer.mapSplit.enable = true
|
}
|
|
num++
|
this.rollerCloseShow = true
|
this.SelectTimeFlag = true
|
this.deactivate()
|
|
// 初始化数据
|
this.leftRollerLayers = this.farmSelectList[0].childItem
|
this.$refs.leftRoller.init()
|
this.rightRollerLayers = this.farmSelectList[0].childItem
|
this.$refs.rightRoller.init()
|
// this.$refs.leftRoller.init()
|
// this.$refs.rightRoller.init()
|
},
|
|
closeRollerShutters () {
|
global.viewer.mapSplit.enable = false
|
this.rollerCloseShow = false
|
this.SelectTimeFlag = false
|
|
this.$refs.leftRoller.clearLayer()
|
this.$refs.rightRoller.clearLayer()
|
|
// global.viewer.imageryLayers.removeAll()
|
},
|
settingViewdata() {
|
getRemoteDetailsList().then(res => {
|
var dataTmp = []
|
dataTmp = getFormat(res.data.data,dataTmp)
|
dataTmp.forEach(item => {
|
global.viewer.imageryLayers.addImageryProvider(
|
new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({
|
url: item.selectItem.url,
|
maximumLevel: 18
|
})
|
)
|
})
|
// this.farmSelectList = dataTmp
|
// this.currentTitle = dataTmp[0].name
|
// this.timeLineList = dataTmp[0].childItem
|
// this.currentObj = dataTmp[0].childItem[0]
|
|
this.farmSelectList=dataTmp
|
this.currentTitle= dataTmp[0].name
|
this.timeLineList= dataTmp[0].childItem
|
this.currentObj= dataTmp[0].selectItem
|
this.currentInd = dataTmp[0].selectItem.index
|
// 初始化地图坐标 默认显示第一个基地
|
global.viewer.camera.setView({
|
// Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
|
// fromDegrees()方法,将经纬度和高程转换为世界坐标
|
destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
|
dataTmp[0].latitude, dataTmp[0].longitude, 1800.0
|
),
|
orientation: {
|
// 指向
|
heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
|
// 视角
|
pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
|
roll: 0.0
|
}
|
})
|
})
|
|
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.eagle-eye-map {
|
position: fixed;
|
right: 10px;
|
bottom: 10px;
|
border: 5px solid orange;
|
border-radius: 50%;
|
width: 200px;
|
height: 200px;
|
z-index: 99;
|
overflow: hidden;
|
}
|
|
.location-box {
|
position: absolute;
|
top: 25px;
|
left: 50px;
|
z-index: 9;
|
width: 485px;
|
display: flex;
|
}
|
.selectname_left {
|
position: absolute;
|
top: 30px;
|
left: 15%;
|
transform: translate(-50%, 0);
|
z-index: 99;
|
}
|
.selectname_right {
|
position: absolute;
|
top: 30px;
|
right: 35%;
|
transform: translate(50%, 0);
|
z-index: 99;
|
}
|
.selectname_index {
|
padding-left: 20px;
|
}
|
|
.l-time {
|
position: absolute;
|
top: 30px;
|
left: 25%;
|
transform: translate(-50%, 0);
|
z-index: 99;
|
}
|
|
.r-time {
|
position: absolute;
|
top: 30px;
|
right: 25%;
|
transform: translate(50%, 0);
|
z-index: 99;
|
}
|
|
.tool-box {
|
display: flex;
|
justify-content: space-between;
|
position: absolute;
|
top: 25px;
|
right: 25px;
|
z-index: 9;
|
|
& > div {
|
display: flex;
|
align-items: center;
|
height: 40px;
|
background: #fff;
|
border-radius: 4px;
|
overflow: hidden;
|
|
.btn {
|
width: 74px;
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
font-size: 12px;
|
color: #717171;
|
cursor: pointer;
|
|
i {
|
margin-right: 6px;
|
vertical-align: middle !important;
|
}
|
}
|
|
.line {
|
width: 0px;
|
height: 24px;
|
border-right: 1px dashed #dcdee1;
|
}
|
}
|
|
.roller-close,
|
.screen-close {
|
margin-left: 30px;
|
width: 40px;
|
height: 40px;
|
background: url(../../../public/img/icon/roller-close.png) no-repeat;
|
background-size: 100% 100%;
|
}
|
|
.func {
|
margin-left: 10px;
|
}
|
}
|
</style>
|