[英]the zoom is not clear in Cesium
i created buttons to zoom to particular countries. 我创建了可缩放到特定国家/地区的按钮。 However when i clicked the button,Singapore it navigate to Singapore but i cant see exactly the Singapore country.
但是,当我单击按钮新加坡时,它导航到新加坡,但我看不到确切的新加坡国家。
So i wanted a better image. 所以我想要一个更好的形象。
Here is my code below... 这是我的下面的代码...
<!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>
My question, if i click Singapore, it will zoom to Singapore just like the second image which i have attached to this question.. What do i need to zoom just like the last image???Can you please help me?? 我的问题是,如果我单击“新加坡”,它将像我已附加到该问题的第二张图片一样缩放到新加坡。我需要像上一张图片一样缩放吗?您能帮我吗? Thank you
谢谢
It looks like your height is too high. 看来您的身高过高。 Try changing
4200000.0
to 42000.0
. 尝试将
4200000.0
更改为42000.0
。
Edit: Here's a more complete code example. 编辑:这是一个更完整的代码示例。 This one turns on labels, so you can see the borders.
这将打开标签,因此您可以看到边框。 Paste this code into Sandcastle and run it with F8.
将此代码粘贴到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
});
Above, I get the default list of imagery providers, and pre-select the one with labels turned on. 在上面,我获得了图像提供者的默认列表,并预先选择了启用了标签的图像提供者。 Then I fly to a point 50km above Singapore, using
duration: 0
to snap the camera there. 然后我飞到新加坡上空50公里处,使用
duration: 0
将相机拍到那里。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.