2017-04-06 71 views
3

我是銫三維地圖js的新手。我想將它與我使用Apache Tomcat作爲Web服務器的現有應用程序集成。我想用這個代替node.js來承載銫。在apache tomcat上託管銫映射

在那裏Getting Started教程和here,他們寫道,你只需要解壓cesium.zip文件並將其託管在你的服務器中。

我在一個名爲CesiumRoot的文件夾中解壓縮了cesium.zip文件,然後我放入了apache的webapps文件夾並啓動了我的服務器。但它沒有奏效。 我搜索了這個問題,什麼也沒找到。

請告訴一個程序或任何教程,告訴如何在Apache中託管它。

+0

它是否給你一個錯誤的信息?你可以檢查瀏覽器控制檯併發布那裏發現的任何相關的錯誤消息? – emackey

回答

1

要在Tomcat或node.js以外的web容器中部署Cesium,您必須在Web應用程序的上下文中解壓縮Cesium發行版,以便HTML頁面,servlet,jsps等可以將URL解析爲銫資源作爲相對URL。

給出一個測試頁的test.html與銫包名爲「銫」文件夾中,該頁面的test.html會提到銫資源如下:

<script src="Cesium/Build/Cesium/Cesium.js"></script> 
    <link rel="stylesheet" type="text/css" href="Cesium/Build/Cesium/Widgets/widgets.css"> 

首先,先從簡單的Hello World應用程序開始。 這裏的test.html的全部內容

<!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>Hello World!</title> 
    <script src="Cesium/Build/Cesium/Cesium.js"></script> 
    <link rel="stylesheet" type="text/css" href="Cesium/Build/Cesium/Widgets/widgets.css"> 
    <style>  
     html, body, #cesiumContainer { 
      width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden; 
     } 
    </style> 
</head> 
<body> 
<div id="cesiumContainer"></div> 
<script> 

var viewer = new Cesium.Viewer('cesiumContainer'); 

</script> 
</body> 
</html> 
+0

如果我沒有互聯網連接,該怎麼辦? 1.如何在離線模式下使用apache託管銫? 2.這個程序也是一樣的每個Os。我正在使用rhel7。 rhel和windows會一樣嗎? – Kiara

+0

由於沒有互聯網連接,銫仍然可以獨立工作,但您需要一個本地圖像和/或地形服務器來承載基本地圖圖像和地形。 – JasonM1

+0

我按照你所說的嘗試過,但它不起作用。我將這些內容解壓縮到一個名爲「Cesium」的文件夾中,並將其放入tomcat的webapps文件夾中,然後啓動服務器,但它不被託管。在控制檯中也沒有錯誤。 什麼可能是沒有託管的問題。 這裏沒有任何教程。我無法找到任何東西。 – Kiara