1.下载arcgis_js_v39_api,需要先注册在下载,现在官网上注册不了。
百度网盘链接: https://pan.baidu.com/s/11PaoD0tnyUACmn6njv8hzA 密码: hf7a
2.部署在本地在tomcat,将下载的文件解压将其中的文件3.9compact改为arcgis_js_v39_api(为了减少文件层数),之后将重命名的文件直接放到tomcat下的webapps下。
3.更改文件下的init.js和dojo.js,将init.js和dojo.js中的41行的位置的"[HOSTNAME_AND_PATH_TO_JSAPI]"改为"localhost:8080/arcgis_js_api/js/dojo/dojo",要是部署到项目中,该路径要与项目部署路径一致
4.测试,按照创建test.html,代码如下:
<!DOCTYPE html>
<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/js/dojo/dijit/themes/tundra/tundra.css" />
<link rel="stylesheet" type="text/css" href="http://localhost:8080/arcgis_js_api/js/esri/css/esri.css" />
<script type="text/javascript" src="http://localhost:8080/arcgis_js_api/init.js"></script>
<script type="text/javascript" src="http://localhost:8080/arcgis_js_api/map.js"></script>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
dojo.require("esri.map");
function init() {
var myMap = new esri.Map("mapDiv");
var myTiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer");
myMap.addLayer(myTiledMapServiceLayer);//使用本地地图图层
}
dojo.addOnLoad(init);//调取init函数
</script>
</head>
<body class="tundra">
<div id="mapDiv" style="width:900px; height:600px; border:1px solid #000;"></div>
</body>
</html>
启动tomcat,直接打开test.html(ie打不开的),效果如下:
恭喜你部署成功!