超图iserver发布的三维服务,加载后不贴地,悬在空中,加载的代码如下:
var url_3d = 'http://127.0.0.1:8090/iserver/services/3d_yun/rest/realspace';
var scene = viewer.scene;
var widget = viewer.cesiumWidget;
try {
//添加S3M图层服务
var promise = scene.open(url_3d);
//***为场景名称
//定位到场景
Cesium.loadJson(url_3d + '/scenes.json').then(function(scenes) {
var sname = scenes[0].name;
Cesium.loadJson(url_3d + '/scenes/' + sname + '.json').then(function(jsonData) {
var cameraPosition = jsonData.camera;
var tilt = Cesium.Math.toRadians(cameraPosition.tilt - 90);
Cesium.when(promise, function(layer) {
//设置相机位置、视角,便于观察场景
scene.camera.setView({
destination: new Cesium.Cartesian3.fromDegrees(cameraPosition.longitude, cameraPosition.latitude,
cameraPosition.altitude),
orientation: {
heading: cameraPosition.heading,
pitch: tilt,
roll: 0
}
});
if (!scene.pickPositionSupported) {
// alert('不支持深度纹理,无法拾取位置!');
}
}, function(e) {
if (widget._showRenderLoopErrors) {
var title = '加载SCP失败,请检查网络连接状态或者url地址是否正确?';
widget.showErrorPanel(title, undefined, e);
}
});
});
});
} catch (e) {
if (widget._showRenderLoopErrors) {
var title = '渲染时发生错误,已停止渲染。';
widget.showErrorPanel(title, undefined, e);
}
}