【发布时间】:2016-07-16 06:31:09
【问题描述】:
这个问题与这两个有关:
- Cesium how to scale a polygon to match Lat-Lon positions while zoom-in/zoom-out
- Cesium - using camera to scale a polygon to match Lat-Lon positions while zoom-in/zoom-out
我遵循的从相机获取纬度-经度-alt 位置的示例代码位于gold standard that appears to be baked into the existing camera controller。使用此代码,我可以从相机的距离检索纬度经纬度位置,以获得几乎与所选原始纬度经度位置和地球表面以上高度完全相同的值。完美!
所有示例和文档都展示了使用度数或度数中的点创建多边形。
现在呢?也许我遗漏了一些东西,但我认为的目的是能够使用特定的 x、y、z 坐标创建多边形,以便在放大、缩小和相机运动。既然我有了这些值,那么用这些值绘制多边形的秘诀是什么?
仅供参考,这些是我目前拥有的价值:
==========================新信息================= ==========
redPolygon 的代码有效:
var redPolygon = viewer.entities.add({
name : 'Red polygon on surface',
polygon : {
hierarchy : Cesium.Cartesian3.fromDegreesArray([-115.0, 37.0,
-115.0, 32.0,
-102.0, 31.0,
-102.0, 35.0,
-102.0, 35.0]),
material : Cesium.Color.RED
}
});
viewer.flyTo(redPolygon);
bluePolygon 的代码不起作用:
var bluePolygon = viewer.entities.add({
name : 'Blue polygon on surface',
polygon : {
//hierarchy: collection.latlonalt,
hierarchy: Cesium.Cartesian3.fromArray(collection.latlonalt),
material : Cesium.Color.BLUE
}
});
viewer.flyTo(bluePolygon);
如果我使用hierarchy: collection.latlonalt,,我会收到以下错误:
所以我将代码更改为 hierarchy: Cesium.Cartesian3.fromArray(collection.latlonalt), 其中 collection.latlonalt 是我的 Cartesian3 数组:
但是什么都画不出来。没有错误。这是我在控制台中看到的:
只是为了测试,我尝试将 z 位置添加到 redPolygon 并将 .fromDegreesArray 更改为 .fromArray,如下所示:
var redPolygon = viewer.entities.add({
name : 'Red polygon on surface',
polygon : {
hierarchy : Cesium.Cartesian3.fromArray([-115.0, 37.0, 10.0,
-115.0, 32.0, 10.0,
-102.0, 31.0, 10.0,
-102.0, 35.0, 10.0,
-102.0, 35.0, 10.0]),
material : Cesium.Color.RED
}
});
viewer.flyTo(redPolygon);
那也没用。
【问题讨论】:
标签: javascript node.js camera terrain cesium