ArcGIS API for JavaScript学习笔记(1)API本地部署

一、API下载

下载地址:https://developers.arcgis.com/downloads/apis-and-sdks?product=javascript
在这里插入图片描述

二、启动IIS功能

点击这两个的复选框,确定之后,可以看到C盘下多出了inetpub文件夹
在这里插入图片描述
在这里插入图片描述

三、API离线部署

将下载下来的API和SDK文件夹内的4.16文件夹复制到inetpub下的wwwroot文件夹之下
在这里插入图片描述

修改下图所示的两个文件“init.js”和“dojo.js”,修改方法为将“init.js”及“dojo.js”文件中的https://[HOSTNAME_AND_PATH_TO_JSAPI]dojo修改为在本地的部署路径http://localhost/4.16API/dojo
在这里插入图片描述

四、验证离线部署

1.使用记事本创建名为test.html文件,并将其置于C:\inetpub\wwwroot\test文件夹下

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>Intro to MapView - Create a 2D map</title>
    <style>
      html,
      body,
      #viewDiv {
     
     
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }
    </style>
    <link rel="stylesheet" href="http://localhost/4.17API/esri/themes/light/main.css" />
    <script src="http://localhost/4.17API/init.js"></script>
    <script>
      require(["esri/Map", "esri/views/MapView"], function(Map, MapView) {
     
     
        var map = new Map({
     
     
          basemap: "topo-vector"
        });
        var view = new MapView({
     
     
          container: "viewDiv", // Reference to the view div created in step 5
          map: map, // Reference to the map object created before the view
          zoom: 4, // Sets zoom level based on level of detail (LOD)
          center: [15, 65] // Sets center point of view using longitude,latitude
        });
      });
    </script>
  </head>
  <body>
    <div id="viewDiv"></div>
  </body>
</html>

2.在浏览器中地址栏中输入http://localhost/test/test.html,如成功实例化出地图则离线部署成功

在这里插入图片描述

3.在浏览器中输入http://localhost/4.17SDK/index.html,出现下图说明SDK离线部署成功

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/baidu_28157641/article/details/108285641