init () {
if (hasInit) {
console.log('hasInit')
clearInterval(this.reloadInterval)
return
}
if (!Cesium || !Cesium.Viewer) {
console.log('Cesium null')
Cesium = window.Cesium
return
}
smviewer = new Cesium.Viewer('cesiumContainerFor', {
shadows: true
})
smviewer.imageryLayers.addImageryProvider(new Cesium.BingMapsImageryProvider({
url: 'https://dev.virtualearth.net',
mapStyle: Cesium.BingMapsStyle.AERIAL,
key: 'AqYgyS1gIIDGsxmOlncqrgA83cHnhClLwZmIJXbYXX36pfxKYtUGk12Q3splaf4Y'
}))
var viewer = smviewer
scene = smviewer.scene
canvas = smviewer.canvas
widget = smviewer.cesiumWidget
for (let i = 0; i < json.s3m.length; i++) {
promiseSet.push(scene.addS3MTilesLayerByScp(json.s3m[i].url, { name: json.s3m[i].name }))
}
for (let i = 0; i < json.fly.length; i++) {
promiseSet.push(scene.addS3MTilesLayerByScp(json.fly[i].url, { name: json.fly[i].name }))
}
Cesium.when.all(promiseSet, function (layers) {
var x, y, z, heading, pitch, roll, up
x = 113.296549; y = 23.385771; z = 16055.958422
heading = 1.5; pitch = -1.5; roll = 0.1; up = 0.1
// 设置地图镜头位置
smviewer.scene.camera.setView({
/* eslint-disable */
destination: new Cesium.Cartesian3.fromDegrees(x, y, z),
orientation:{
heading: heading,
pitch: pitch,
roll: roll,
up: up
}
})
for (var i = 0; i < layers.length; i++) {
for (let j = 0; j < json.fly.length; j++) {
if (json.fly[j].name === layers[i].name) {
// var layer = layers[i]
var layer = layers[i]
console.log(layer.name.substring(0, layer.name.indexOf('@')))
layer.setQueryParameter({
url: 'http://develop.roywise.cn:31080/iserver/services/data-max/rest/data',
dataSourceName: '白云机场数据库',
dataSetName: layer.name.substring(0, layer.name.indexOf('@')),
Keyword: 'SmID'
})
}
}
}
}, function () {
console.log('加载SCP失败,请检查网络连接状态或者url地址是否正确?')
})
var _that = this
smviewer.pickEvent.addEventListener(function (feature) {
console.log('1111111111111111111111111111111', feature)
})
// // 设置右键按下图层
var handler = new Cesium.ScreenSpaceEventHandler(smviewer.canvas);
handler.setInputAction(function(event) {
_that.getClickNo('land')
}, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)
hasInit = true
this.getOver()
if (hasInit === true) {
that.dataJump()
}
}