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>
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那个。