代码之家  ›  专栏  ›  技术社区  ›  user8497764

铯的变焦不清晰

  •  1
  • user8497764  · 技术社区  · 8 年前

    我创建了按钮来缩放到特定的国家。然而,当我点击按钮,新加坡它导航到新加坡,但我不能看到确切的新加坡国家。 enter image description here

    所以我想要一个更好的形象。 enter image description here

    <!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>
    

    我的问题是,如果我点击新加坡,它将缩放到新加坡,就像我附加在这个问题上的第二张图片一样。。我需要什么才能像上一张图像一样缩放???你能帮帮我吗??非常感谢。

    1 回复  |  直到 8 年前
        1
  •  0
  •   emackey    8 年前

    看起来你的身高太高了。尝试更改 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
    });
    

    duration: 0