yu
1使用方式1
在当点击某个按钮时可调用方法,视角即可到达此范围
flyChina2: function() {
// 标准的定位 如下
var e={"x":116.71583137391825,"y":39.3057840890112,"z":58422.767432990586,"heading":0.030187883201016064,"pitch":-0.8163329111616555,"rool":3.630530240883445e-7}
_cStatic.setCameraView(e);
},
2使用方式2
设置系统初始化视角用
var exe2={"x":102.54188522577022,"y":24.94810332575949,"z":589.1030221680712,"heading":1.0113979966161253,"pitch":-0.45688812871505746,"rool":0.002422466806493162};
var exjons=exe2;//JSON.parse(exe2);
exjons.complete=function(){
// ak_nav.showlinedt();
};
_cStatic.setCameraView(exjons);
exe2={"x":102.54188522577022,"y":24.94810332575949,"z":589.1030221680712,"heading":1.0113979966161253,"pitch":-0.45688812871505746,"rool":0.002422466806493162};
这个视角的来源,需要自己调整好地图位置,然后调用获取视角的方法,在浏览器内console.log内输出,拷贝即可
获取可以在某个方法下执行,
实现代码
如下
_cStatic.getCameraView()
源码如下:(实际无需源码,直接调用 _cStatic. 即可)
/**
获取当前范围
视野角度
*/
getCameraView:function() {
var camera = viewer.camera;
var position = camera.position;
var heading = camera.heading;
var pitch = camera.pitch;
var roll = camera.roll;
var lnglat = Cesium.Cartographic.fromCartesian(position);
return {
x: Cesium.Math.toDegrees(lnglat.longitude),
y: Cesium.Math.toDegrees(lnglat.latitude),
z: lnglat.height,
heading: heading,
pitch: pitch,
rool:roll
}
},
/**
根据范围json数据进行定位
*/
setCameraView:function(obj) {
if (!obj) return;
var position = Cesium.Cartesian3.fromDegrees(obj.x, obj.y, obj.z);
viewer.camera.flyTo({
destination: position,
duration: obj.duration || 3,
complete: obj.complete,
orientation: {
heading:obj.heading,
pitch:obj.pitch,
roll:obj.roll
},
});
},