首页 > 代码库 > ArcGIS API for Javascript配置
ArcGIS API for Javascript配置
1、去官网下载最新版: ArcGIS API for JavaScript 3.9
2、分别解压两个压缩包,然后把 arcgis_js_v39_api\arcgis_js_v39_api\arcgis_js_api 文件夹下的 library 文件夹放到 arcgis_js_v39_sdk\arcgis_js_api 文件夹下面,如:
接着把arcgis_js_v39_sdk部署到IIS上
在浏览器中输入:http://<myserver>/arcgis_js_v39_sdk/install.htm ,效果如下
点击 ArcGIS API for JavaScript 连接跳转到如下页面(可能会出错,原因是在library文件夹下面间隔了一个叫3.9的文件夹,完整路径为:http://<myserver>/arcgis_js_v39_sdk/arcgis_js_api/library/3.9/install.htm):
3、有4个地方修改:
1)、打开 arcgis_js_v39_sdk\arcgis_js_api\library\3.9\3.9\init.js 找到 ‘[HOSTNAME_AND_PATH_TO_JSAPI]‘, 修改为 "<myserver>/arcgis_js_api/library/3.9/3.9/"
2)、打开 arcgis_js_v39_sdk\arcgis_js_api\library\3.9\3.9\js\dojo\dojo\dojo.js 找到 ‘[HOSTNAME_AND_PATH_TO_JSAPI]‘, 修改为 "<myserver>/arcgis_js_api/library/3.9/3.9/"
3)、打开 arcgis_js_v39_sdk\arcgis_js_api\library\3.9\3.9compact\init.js 找到 ‘[HOSTNAME_AND_PATH_TO_JSAPI]‘, 修改为 "<myserver>/arcgis_js_api/library/3.9/3.9compact/"
4)、打开 arcgis_js_v39_sdk\arcgis_js_api\library\3.9\3.9compact\js\dojo\dojo\dojo.js 找到 ‘[HOSTNAME_AND_PATH_TO_JSAPI]‘, 修改为 "<myserver>/arcgis_js_api/library/3.9/3.9compact/"
到此配置已经完成。
4、测试
可以通过他自带的一段代码进行测试(别忘了将<myserver>修改为自己的服务器地址):
<!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://<myserver>/arcgis_js_api/library/3.9/3.9/js/dojo/dijit/themes/tundra/tundra.css"/> <link rel="stylesheet" type="text/css" href="http://<myserver>/arcgis_js_api/library/3.9/3.9/js/esri/css/esri.css" /> <script type="text/javascript" src="http://<myserver>/arcgis_js_api/library/3.9/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="tundra"> <div id="mapDiv" style="width:900px; height:600px; border:1px solid #000;"></div> </body></html>
效果如下:
ArcGIS API for Javascript配置