48 lines
1.5 KiB
HTML
48 lines
1.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link href="./Widgets/widgets.css" rel="stylesheet">
|
|
<script src="./Cesium.js"></script>
|
|
<title>Document</title>
|
|
</head>
|
|
<body>
|
|
|
|
<div style="width:100%;height:600px" id="cesiumContainer"></div>
|
|
|
|
</body>
|
|
<script>
|
|
function onload(Cesium) {
|
|
var viewer = new Cesium.Viewer('cesiumContainer');
|
|
var scene=viewer.scene
|
|
//在此实现添加影像
|
|
//viewer.scene.open('http://localhost:8090/iserver/services/3D-FCBIMResult/rest/realspace')
|
|
var promise=viewer.scene.open('http://223.99.16.253:8090/iserver/services/3D-chengquall/rest/realspace')
|
|
|
|
var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
|
|
handler.setInputAction(function(e) {
|
|
// 获取点击位置笛卡尔坐标
|
|
var position = scene.pickPosition(e.position);
|
|
var position2 = new Cesium.Cartographic.fromCartesian(position);
|
|
console.log(position2);
|
|
var height2 = viewer.scene.sampleHeight(position2);
|
|
console.log(height2);
|
|
|
|
// 经纬度转笛卡尔
|
|
var position3 = new Cesium.Cartographic(Cesium.Math.toRadians(117.973724),Cesium.Math.toRadians(35.278375));
|
|
console.log("position3",position3)
|
|
//获取模型高度
|
|
var height3 = viewer.scene.sampleHeight(position3);
|
|
alert(height3);
|
|
|
|
|
|
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
|
|
}
|
|
if (typeof Cesium !== 'undefined') {
|
|
window.startupCalled = true;
|
|
onload(Cesium);
|
|
}
|
|
</script>
|
|
</html> |