代码改变世界

ArcGIS API for JavaScript 离线部署

2017-09-12 10:09  iForget7  阅读(580)  评论(0编辑  收藏  举报

1.解压缩API文件

2.打开install.html,参考部署

 

 

3.拷贝 \arcgis_js_api\library 和其包含的所有内容到IIS服务器的目录下,例如 C:\Inetpub\wwwroot\arcgis_js_api\library

 

4.安装部署API

  在编辑工具中打开 C:\Inetpub\wwwroot\arcgis_js_api\library\4.4\dojo\dojo.js ,搜索 [HOSTNAME_AND_PATH_TO_JSAPI], 替换为 localhost/arcgis_js_api/library/4.4/

  注意:localhost 表示本地地址,如果是服务需使用IP或者域名

  在编辑工具中打开 C:\Inetpub\wwwroot\arcgis_js_api\library\4.4\init.js ,搜索 [HOSTNAME_AND_PATH_TO_JSAPI], 替换为 localhost/arcgis_js_api/library/4.4/

5.测试是否部署成功

测试代码如下,拷贝至C:\Inetpub\wwwroot\下,在浏览器中输入 https://localhost/test.thml   (IIS 开启 https 协议请参考另一篇博客)

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" />
    <title>Test Map</title>
    <link rel="stylesheet" href="https://localhost/arcgis_js_api/library/4.4/dijit/themes/claro/claro.css" />
    <link rel="stylesheet" href="https://localhost/arcgis_js_api/library/4.4/esri/css/main.css" />
    <style>
        html,
        body,
        #viewDiv {
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100%;
        }
    </style>
    <script src="https://localhost/arcgis_js_api/library/4.4/dojo/dojo.js"></script>
    <script>
        require([
            "esri/Map",
            "esri/views/MapView",
            "esri/widgets/BasemapToggle",
            "dojo/domReady!"
        ], function(
            Map,
            MapView,
            BasemapToggle
        ) {

            // Create the Map with an initial basemap
            var map = new Map({
                basemap: "topo"
            });

            // Create the MapView and reference the Map in the instance
            var view = new MapView({
                container: "viewDiv",
                map: map,
                center: [-86.049, 38.485],
                zoom: 3
            });
        });
    </script>
</head>
<body class="claro">
<div id="viewDiv"></div>
</body>
</html>