将Cesium globe的默认视图设置为特定国家/地区

时间:2015-12-30 07:35:33

标签: cesium

默认情况下,Cesium globe专注于美国,如下所示

enter image description here

但我希望将特定国家/地区视为默认国家(例如:印度)。我尝试了很多方法,比如设置相机位置等。

1 个答案:

答案 0 :(得分:0)

此问题已被问及herehere。您可以像以下一样为印度国家调整这些答案:

var west = 68.0;
var south = 7.0;
var east = 89.0;
var north = 35.0;

var rectangle = Cesium.Rectangle.fromDegrees(west, south, east, north);

Cesium.Camera.DEFAULT_VIEW_FACTOR = 0.5;
Cesium.Camera.DEFAULT_VIEW_RECTANGLE = rectangle;

// NOTE: Viewer constructed after default view is set.
var viewer = new Cesium.Viewer('cesiumContainer', {
    navigationHelpButton: false, animation: false, timeline: false
});
html, body, #cesiumContainer {
  width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden;
  font-family: sans-serif;
}
<link href="http://cesiumjs.org/releases/1.16/Build/Cesium/Widgets/widgets.css" 
      rel="stylesheet"/>
<script src="http://cesiumjs.org/releases/1.16/Build/Cesium/Cesium.js">
</script>
<div id="cesiumContainer"></div>