2. 将下载下来的 arcgis_js_v26_api.zip 和 arcgis_js_v26_sdk.zip 分别解压,将各自文件夹下的的 arcgis_js_api 文件夹拷贝到 C:\inetpub\wwwroot 下,因为拷贝的文件夹名称都为arcgis_js_api,因此当拷贝第二个文件夹时选择覆盖即可;
3. 将 C:\inetpub\wwwroot\arcgis_js_api\library\2.6\jsapi\js\esri 下的 esri.js 文件
C:\inetpub\wwwroot\arcgis_js_api\library\2.6\jsapi\js\dojo\dojo 下的 dojo.xd.js 及dojo.xd.js.uncompressed.js 两个文件
中的 "[HOSTNAME_AND_PATH_TO_JSAPI] 替换为 djConfig.url + "/arcgis_js_api/library/2.6/jsapi/ (注意别少了冒号)
同理将
C:\inetpub\wwwroot\arcgis_js_api\library\2.6\jsapicompact\js\esri 下的 esri.js 文件
C:\inetpub\wwwroot\arcgis_js_api\library\2.6\jsapicompact\js\dojo\dojo 下的 dojo.xd.js 及dojo.xd.js.uncompressed.js 两个文件
中的 "[HOSTNAME_AND_PATH_TO_JSAPI] 替换为 djConfig.url + "/arcgis_js_api/library/2.6/jsapicompact/ (注意冒号);
4. 在IIS中将 arcgis_js_api 转换为应用程序,并在默认文档中添加:default.ashx ;
5. var djConfig = { parseOnLoad: true, url: "localhost" }; 加一个url属性,url为api所在服务器IP地址
将 http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.6 替换为http://localhost/arcgis_js_api/library/2.6/jsapi localhost要改为api所在服务器IP地址
将 http://serverapi.arcgisonline.com/jsapi/arcgis/2.6/js/dojo/dijit/themes/claro/claro.css 替换为
修改后的代码如下: 如果换地方部署,只要将本地的arcgis_js_api 文件夹直接拷贝过去并进行上边第4、5(改为api所在服务器IP地址)步的操作就可以了
2
3
4
5
6
8
9
10
11
28 var djConfig = { parseOnLoad: true, url: "localhost" };
29
30
31 dojo.require("dijit.layout.BorderContainer");
32 dojo.require("dijit.layout.ContentPane");
33 dojo.require("esri.map");
34
35 var map;
36
37 function init() {
38 var initExtent = new esri.geometry.Extent({ "xmin": -122.46, "ymin": 37.73, "xmax": -122.36, "ymax": 37.77, "spatialReference": { "wkid": 4326} });
39 map = new esri.Map("map", {
40 extent: esri.geometry.geographicToWebMercator(initExtent)
41 });
42 // Add the topographic layer to the map. View the ArcGIS Online site for services http://arcgisonline/home/search.html?t=content&f=typekeywords:service
43 var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
44 map.addLayer(basemap);
45
46 dojo.connect(map, 'onLoad', function (theMap) {
47 // resize the map when the browser resizes
48 dojo.connect(dijit.byId('map'), 'resize', map, map.resize);
49 });
50 }
51
52 dojo.addOnLoad(init);
53
54
55
56 57 height: 100%; margin: 0;">
58 59 padding: 0;">
60
61
62
若想让自己机器的rest服务调用的javascript api也使用离线文件,可修改C:\inetpub\wwwroot\ArcGIS\rest 下的 rest.config 文件,修改其中的两个节点为:
http://locahost/arcgis_js_api/library/2.6/jsapi/
http://locahost/arcgis_js_api/library/2.6/jsapi/js/dojo/dijit/themes/tundra/tundra.css(localhost改为api所在服务器)