Arcgis javascript api離線開發環境搭建


1.現在官網上下載javascript api2.5.http://www.esri.com/apps/products/download/index.cfm?fuseaction=download.all#ArcGIS_API_for_JavaScript

(Concepts→Getting started→Get the arcgis api for javascript→Download→ArcGIS API for JavaScript download page )

2. 將下載好的壓縮包解壓;

3. 將解壓的離線包拷貝到 Tomcat 應用程序目錄 webapps 下 (如我的 機器地址為 D:\apache-tomcat-6.0.35-windows-x64\apache-tomcat-6.0.35\webapps\arcgis_js_api) ;

4. 用notepad打開 D:\apache-tomcat-6.0.35-windows-x64\apache-tomcat-6.0.35\webapps\arcgis_js_api\library\2.5\arcgis\js\esri 目錄下的 esri.js 文件,找到 [HOSTNAME_AND_PATH_TO_JSAPI]並將其改為 <myserver>/arcgis_js_api/library/2.5/arcgis/ ,如我的機器上地址為: localhost:8080//arcgis_js_api/library/2.5/arcgis/;

5. 打開 D:\apache-tomcat-6.0.35-windows-x64\apache-tomcat-6.0.35\webapps\arcgis_js_api\library\2.5\arcgis\js\dojo\dojo 目錄,打開 dojo.xd.js 文件, 同樣將文件 內所有[HOSTNAME_AND_PATH_TO_JSAPI]改為 <myserver>/arcgis_js_api/library/2.5/arcgis/;打開 dojo.xd.js.uncompressed.js 文件,將所有 [HOSTNAME_AND_PATH_TO_JSAPI]改為 <myserver>/arcgis_js_api/library/2.5/arcgis/;
6. 打開 D:\apache-tomcat-6.0.35-windows-x64\apache-tomcat-6.0.35\webapps\arcgis_js_api\library\2.5\arcgis_compact\js\esri 目錄,找到 esri.js,將 [HOSTNAME_AND_PATH_TO_JSAPI]改為 <myserver>/arcgis_js_api/library/2.5/arcgis_compact/;

7. 打開 D:\apache-tomcat-6.0.35-windows-x64\apache-tomcat-6.0.35\webapps\arcgis_js_api\library\2.5\arcgis_compact\js\dojo\dojo 目錄,打開 dojo.xd.js 文件同樣將文件 內所有[HOSTNAME_AND_PATH_TO_JSAPI]改為 <myserver>/arcgis_js_api/library/2.5/ arcgis_compact/;打開 dojo.xd.js.uncompressed.js 文件,將所有 [HOSTNAME_AND_PATH_TO_JSAPI]改為 <myserver>/arcgis_js_api/library/2.5/ arcgis_compact /;

8. 在 Tomcat 的 conf 文件夾下找到 web.xml,在歡迎頁面處加上index.jsp,如圖所示

9. 啟動 Tomcat,在瀏覽器中輸入http://localhost:8080/arcgis_js_api/library/2.5/arcgis/index.jsp 如果能出現下載頁面


則說明安裝正常

10. 測試代碼

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Simple Map</title>
    <link rel="stylesheet" type="text/css" href="http://localhost:8080/arcgis_js_api/library/2.5/arcgis/js/dojo/dijit/themes/tundra/tundra.css">
    <script type="text/javascript" src="http://localhost:8080/arcgis_js_api/library/2.5/arcgis_compact"></script>
    <script type="text/javascript">
    dojo.require("esri.map");
      function init() {
        var myMap = new esri.Map("mapDiv");
        //note that if you do not have public Internet access then you will need to point this url to your own locally accesible cached service.
        var myTiledMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://localhost:8399/arcgis/rest/services/usa1/MapServer");
        myMap.addLayer(myTiledMapServiceLayer);
      }
      dojo.addOnLoad(init);
    </script>
  </head>
  <body class="tundra">
    <div id="mapDiv" style="width:900px; height:600px; border:1px solid #000;"></div>
  </body>
</html>

改自:http://wenku.baidu.com/view/e1e3c43e376baf1ffc4fad30?pn=2&ssid=&from=&bd_page_type=1&uid=wk_1342147165_734&pu=sl@1,pw@1000,sz@224_220,pd@1,fz@2,lp@0,tpl@color,&st=1&wk=rd&maxpage=2

遇到的問題:

1.地圖服務換一個路徑換一張mxd,就讀取不出來。但是重啟下電腦就好,於是我就想到應該是“服務”的問題,服務中有個Arcgis Server Manager Service服務,重啟它就好了。

2.在瀏覽器輸入服務地址:http://localhost:8399/arcgis/services/usa/MapServer遭遇以下錯誤。

        “HTTP Status 405 - HTTP method GET is not supported by this URL”
type Status report
messHTTP method GET is not supported by this URL
descrThe specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL)

原因:這個是soap api的地址,瀏覽器無法查看。瀏覽器只能查看rest地址,改成:http://localhost:8399/arcgis/rest/services/usa/MapServer

3.

 

 

 4. 因為解壓多了一級目錄,導致路徑出錯。

 5.頁面提示dojo未定義。dojo.require("esri.map")這句報錯,dojo未定義(官方bug),部署arcgis_compact下面的js即可,部署 arcgis下的js不行。

 6地圖區別: 用ArcGISTiledMapServiceLayer初始化的這個只能加載切片地圖,非切片地圖要用Dynamic那個。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM