1、部署前提:
安装好ArcGIS Server,Tomcat,我使用的Server版本是10.2,Tomcat版本是7.0.542、部署步骤:
1)下载ArcGIS API for JavaScript v3.11 API和SDK
2)解压API和SDK,将二者解压出来的arcgis_js_api文件夹均拷到tomcat的webapps目录下
3)修改以下四个文件:
apache-tomcat-7.0.54\webapps\arcgis_js_api\library\3.11\3.11\init.js
apache-tomcat-7.0.54\webapps\arcgis_js_api\library\3.11\3.11\dojo\dojo\dojo.js
将以上两个文件内的所有“[HOSTNAME_AND_PATH_TO_JSAPI]”改成"localhost:8080/arcgis_js_api/library/3.11/3.11/"
apache-tomcat-7.0.54\webapps\arcgis_js_api\library\3.11\3.11compact\init.js
apache-tomcat-7.0.54\webapps\arcgis_js_api\library\3.11\3.11compact\dojo\dojo\dojo.js
将以上两个文件内的所有“[HOSTNAME_AND_PATH_TO_JSAPI]”改成"localhost:8080/arcgis_js_api/library/3.11/3.11compact/"
4)在ArcGIS安装目录下搜索rest-config.properties,在#JS API URLs部分修改为以下内容
jsapi.arcgis=http://localhost:8080/arcgis_js_api/library/3.11/3.11/init.js
jsapi.arcgis.sdk=http://localhost:8080/arcgis_js_api/sdk
jsapi.arcgis.css=http://localhost:8080/arcgis_js_api/library/3.11/3.11/dojo/dijit/themes/tundra/tundra.css
jsapi.arcgis.css2=http://localhost:8080/arcgis_js_api/library/3.11/3.11/esri/css/esri.css
3、离线测试:
1)测试网页:
<!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/3.11/3.11/dijit/themes/tundra/tundra.css"/>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/arcgis_js_api/library/3.11/3.11/esri/css/esri.css" />
<script type="text/javascript" src="http://localhost:8080/arcgis_js_api/library/3.11/3.11/init.js"></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 accessible cached service.
var myTiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/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>
2)通过浏览器开发者工具可以看到调用的是本地的Javascript API文件。