我创建了缩放到特定国家/地区的按钮。然而,当我点击按钮,新加坡它导航到新加坡,但我无法看到新加坡国家。
以下是我的代码......
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Use correct character set. -->
<meta charset="utf-8">
<!-- Tell IE to use the latest, best version. -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Make the application on mobile take up the full browser screen and disable user scaling. -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<title>My Work</title>
<script src="../Build/Cesium/Cesium.js">
</script>
<style>
@import url(../Build/Cesium/Widgets/widgets.css);
html, body, #cesiumContainer {
width: 98%; height: 98%; margin: 0; padding: 0; overflow: hidden;
}
</style>
</head>
<body>
<div id="cesiumContainer">
<button type="button" class="cesium-button" onclick = "zoomToSingapore();" data-toggle="tooltip" data-placement="bottom" title="Please click me if you want to zoom to Singapore">Zoom To Singapore</button>
<button type="button" class="cesium-button" onclick = "zoomToMalaysia();" data-toggle="tooltip" data-placement="bottom" title="Please click me if you want to zoom to Malaysia">Zoom To Malaysia</button>
</div>
<div id="cesiumContainer" style="position:absolute;top:24px;right:24px;width:38px;height:38px;"></div>
<script>
viewer = new Cesium.Viewer('cesiumContainer', {
timeline: false,
navigationHelpButton: false,
infoBox: false
});
function zoomToSingapore()
{
var singapore = Cesium.Cartesian3.fromDegrees(103.851959, 1.290270);
viewer.camera.lookAt(singapore, new Cesium.Cartesian3(0.0, 0.0, 4200000.0));
}
function zoomToMalaysia()
{
var malaysia = Cesium.Cartesian3.fromDegrees(101.9758, 4.2105);
viewer.camera.lookAt(malaysia, new Cesium.Cartesian3(0.0, 0.0, 4200000.0));
}
</script>
</body>
</html>
我的问题是,如果我点击新加坡,它会缩放到新加坡,就像我附加到这个问题的第二张图片一样。我需要像最后一张图像一样放大吗?你能帮我吗? ?谢谢
答案 0 :(得分:0)
看起来你的身高太高了。尝试将4200000.0
更改为42000.0
。
编辑:这是一个更完整的代码示例。这个打开标签,你可以看到边框。将此代码粘贴到Sandcastle并使用F8运行。
var imagery = Cesium.createDefaultImageryProviderViewModels();
var viewer = new Cesium.Viewer('cesiumContainer', {
imageryProviderViewModels: imagery,
selectedImageryProviderViewModel: imagery[1]
});
var height = 50000;
var singapore = Cesium.Cartesian3.fromDegrees(103.85, 1.33, height);
viewer.camera.flyTo({
destination: singapore,
duration: 0
});
在上面,我获得了图像提供者的默认列表,并预先选择打开标签的图像。然后我飞到新加坡以上50公里的地方,用duration: 0
将相机拍到那里。