我想要在Cesium中可視化一些3d數據點,但不想設置服務器。我下載了Cesium-1.34.zip並將其解壓到桌面。然後我創建了一個.html文件,它也位於我的桌面上,並從Cesium-1.34解壓縮的文件夾中提取資源。我包含http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=PolylineVolume.html&label=Geometries的一些示例代碼來測試它。我的代碼全部如下:實體未出現在CesiumJS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1,
maximum-scale=1, minimum-scale=1, user-scalable=no">
<title>Hello World!</title>
<script src="Cesium-1.34/Build/Cesium/Cesium.js"></script>
<style>
@import url(Cesium-1.34/Apps/Sandcastle/templates/bucket.css);
@import url(Cesium-1.34/Build/Cesium/Widgets/widgets.css);
html, body, #cesiumContainer {
width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden;
}
</style>
</head>
<body>
<div class="fullSize" id="cesiumContainer"></div>
<div id="loadingOverlay"><h1>Loading...</h1></div>
<div id="toolbar"></div>
<script>
var viewer = new Cesium.Viewer('cesiumContainer', {
baseLayerPicker: false,
imageryProvider: new Cesium.BingMapsImageryProvider({
url : 'http://dev.virtualearth.net',
key : 'al3lvBftgu3T17GnraSB~sDScxf9wA4dopWEvK2swfA~AlwqHWs4LzhiC2oOHAFYe9dZMVQtYCQHRGyC8Y6Hyq9-109ibBI9suhwFj0RoRAp'
})
});
var greenBox1 = viewer.entities.add({
name : 'Green box with beveled corners and outline',
polylineVolume : {
positions : Cesium.Cartesian3.fromDegreesArrayHeights([-90.0, 32.0, 0.0,
-90.0, 36.0, 100000.0,
-94.0, 36.0, 0.0]),
shape :[new Cesium.Cartesian2(-50000, -50000),
new Cesium.Cartesian2(50000, -50000),
new Cesium.Cartesian2(50000, 50000),
new Cesium.Cartesian2(-50000, 50000)],
cornerType : Cesium.CornerType.BEVELED,
material : Cesium.Color.GREEN.withAlpha(0.5),
outline : true,
outlineColor : Cesium.Color.BLACK
}
});
viewer.zoomTo(viewer.entities);
</script>
</body>
</html>
問題是,應該出現在地球上的綠色框不在那裏。我沒有從開發者工具窗口得到任何錯誤。我確實收到了一些警告和消息:
- 警告:DOM7011:此頁面上的代碼禁用後退和前進緩存。
- 消息:HTML1300:導航發生。
- 消息:WEBGL11258:臨時切換到軟件渲染以顯示WebGL內容。此應用程序正在使用Cesium的默認Bing地圖密鑰。請儘快爲應用程序創建一個新的密鑰...
有關該密鑰的消息很奇怪,因爲我絕對在代碼中使用自己的密鑰,儘管我不認爲這會干擾實體沒有出現任何錯誤。在這一點上,我非常難過,我認爲如果一個實體不能顯示就會出現錯誤,但我什麼也沒得到。這可能是因爲它確實需要在服務器上運行。任何提示我缺少的東西或如何在CesiumJS上僅使用本地配置來繪製實體?
謝謝!我不確定在整個安裝過程中如何通過本地運行沙盒。現在,我不必浪費時間在沒有服務器的情況下使其工作。 – jvc