一般引用ArcGIS API for JavaScript开发有两种方式:一种是直接引用官方提供的API地址(http://js.arcgis.com/3.14/),另外一种是自己发布一个本地的API服务,下面介绍一下在本机发布一个本地的API服务。
第一步:到?https://developers.arcgis.com/en/downloads/?网站下载API,需要注册eari的账户才能下载,进入网站后找到ArcGIS Web SDKs?下的ArcGIS API for JavaScript选择版本后,点击
进行下载。或者到链接:http://pan.baidu.com/s/1pJL4YuB?密码:m9d4 下载。
?
第二步,解压API压缩文件,找到压缩文件下arcgis_js_v314_api\arcgis_js_api\library\3.14目录下的3.14文件夹,
将其放到Tomcat的webapps\jspai目录下,注意,jsapi文件是需要自己创建的,目的是为了和别的服务进行区分和方便管理各版本的API,读者可以随意取名。例如:D:\Tomcat\webapps\jsapi
第三步,修改配置,有两处需要修改,第一处3.14\init.js文件,第二处3.14\dojo\dojo.js文件。注意,为了不发生端口的冲突可将Tomcat的端口号修改为8090,打开D:\Tomcat\conf\server.xml文件,修改端口为8090。
第一处,用文本编辑器打开3.14\init.js文件,Ctrl+F全文搜索[HOSTNAME_AND_PATH_TO_JSAPI],将其替换为localhost:8090/jspai/3.14,
替换后:
同样替换第二处。
第四步,启动Tomcat,双击运行D:\Tomcat\bin\startup.bat。
第五步,创建html文件,内容如下运行测试
[html]?view plaincopy
</pre><pre?name="code"?class="html"><!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:8090/jsapi/3.14/dijit/themes/tundra/tundra.css"/>??
????<link?rel="stylesheet"?type="text/css"?href="http://localhost:8090/jsapi/3.14/esri/css/esri.css"?/>??
????<script?type="text/javascript"?src="http://localhost:8090/jsapi/3.14/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>??
成功显示:
转自:http://blog.csdn.net/u013274055/article/details/49382661
ArcGis API for JavaScript 3.14 基于tomcat配置
原文:http://www.cnblogs.com/xiangxs/p/5122074.html