ArcGIS 10.2 JavaScript API本地部署离线开发环境
2016-09-23 08:52
585 查看
转:http://www.cnblogs.com/oceanking/p/3930305.html
解压后在IIS中建立应用程序,如下图。配置好API应用程序后,其路径为http://localhost/arcgis_js_api
ARCGIS JavaScript API包括普通版和简化版,简化版移除了Dojo Digit依赖和非必须的ArcGIS JSAPI类。
为了简化js网站目录,这里把含有init.js的名为3.9的文件夹即原有的arcgis_js_api/library/3.9/3.9 剪切到arcgis_js_api下,删除library文件夹。我不需要compact压缩版,因此已将其连同library文件夹一并删除。
注意,127.0.0.1只用于本机访问,如果要让网络上其他电脑访问,需要填入本机的ip地址,最好是本机的域名。也可以用document.domain方式获取域名,但这不适用于本机访问,因为本机访问时document.domain可能获得localhost,而localhost填入这里会导致异常。
到此为止,开发库已经配置完成。
下面进行简单的测试。把下面的代码保存为test.htm,存到iis或tomcat的web目录里,在浏览器中输入网址的方式访问,不要直接双击htm文件打开。
<!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/arcgis_js_api/3.9/js/dojo/dijit/themes/tundra/tundra.css"/>
<link rel="stylesheet" type="text/css" href="http://localhost/arcgis_js_api/3.9/js/esri/css/esri.css" />
<script type="text/javascript" src="http://localhost/arcgis_js_api/3.9/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="esri">
<div id="mapDiv" style="width:900px; height:600px; border:1px solid #000;"></div>
</body>
</html>
若在tomcat下部署,注意端口号的修改。
1 获取ArcGIS JavaScript API
API的下载地址http://support.esrichina.com.cn/2011/0223/960.html,在下载页面会看到api和sdk的下载链接,api是我们开发需要的库,sdk是说明文档和例子,点击下载api的最新版3.9。2 本地部署API
打开API包中的arcgis_js_api/library/install.htm安装说明,本文依据此英文说明而来。解压后在IIS中建立应用程序,如下图。配置好API应用程序后,其路径为http://localhost/arcgis_js_api
ARCGIS JavaScript API包括普通版和简化版,简化版移除了Dojo Digit依赖和非必须的ArcGIS JSAPI类。
为了简化js网站目录,这里把含有init.js的名为3.9的文件夹即原有的arcgis_js_api/library/3.9/3.9 剪切到arcgis_js_api下,删除library文件夹。我不需要compact压缩版,因此已将其连同library文件夹一并删除。
配置普通版:
打开 arcgis_js_api\3.9\init.js,把"[HOSTNAME_AND_PATH_TO_JSAPI]js/dojo/dojo"替换成 api在本地机器上的部署路径,即 "127.0.0.1/arcgis_js_api/library/3.2/jsapi/",注意路径无需包含 http:// 打开 arcgis_js_api\3.9\js\dojo\dojo\dojo.js,把"[HOSTNAME_AND_PATH_TO_JSAPI]js/dojo/dojo"替换成api在本地机器上的部署路径。这里是 "127.0.0.1/arcgis_js_api/3.9/js/dojo/dojo"注意路径无需包含http://注意,127.0.0.1只用于本机访问,如果要让网络上其他电脑访问,需要填入本机的ip地址,最好是本机的域名。也可以用document.domain方式获取域名,但这不适用于本机访问,因为本机访问时document.domain可能获得localhost,而localhost填入这里会导致异常。
到此为止,开发库已经配置完成。
下面进行简单的测试。把下面的代码保存为test.htm,存到iis或tomcat的web目录里,在浏览器中输入网址的方式访问,不要直接双击htm文件打开。
<!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/arcgis_js_api/3.9/js/dojo/dijit/themes/tundra/tundra.css"/>
<link rel="stylesheet" type="text/css" href="http://localhost/arcgis_js_api/3.9/js/esri/css/esri.css" />
<script type="text/javascript" src="http://localhost/arcgis_js_api/3.9/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="esri">
<div id="mapDiv" style="width:900px; height:600px; border:1px solid #000;"></div>
</body>
</html>
若在tomcat下部署,注意端口号的修改。
相关文章推荐
- JS原生 之------放烟花喽
- JSONP(手写一个跨域组件)
- Js删除table内的某一行
- canvas制作 加载圆
- canvas经典太极
- 同步异步动态引入js文件的几种方法总结
- Promise.then fired with only one argument?
- form表单转Json提交的方法(推荐)
- 力导向图练习
- JS图片左右无缝隙滚动的实现(兼容IE,Firefox 遵循W3C标准)
- html css js 时钟 计时器
- javascript完整表单验证
- javascript requestAnimationFrame vs. setTimeout
- js判断两个数组的类容是否相同
- js 博饼小游戏
- JS弹出窗口代码大全(详细整理)
- 【一句话学习】新手向--Javascript--(持续更新)
- 关于jsp里url中的参数中文乱码问题
- XML基础
- javascript中的string对象