您的位置:首页 > Web前端 > JavaScript

arcgis api for javascript 4.4 开发环境搭建

2017-08-22 11:12 363 查看
本次搭建是在tomcat下进行的,不懂的可以去查阅相关资料

1、首先需要下载arcgis api 4.4开发包,下载链接有两个

  http://download.csdn.net/download/u013816904/9944003 或者官网链接 https://developers.arcgis.com/downloads
2、解压开发包,并放到tomcat/webapps下面,如图



3、arcgis api 4.4开发包只需要修改dojo.js一个文件即可,下图为文件路径



打开dojo.js文件,把localhost:8099替换为你电脑的ip地址和tomcat的端口,如图所示



4、检测环境

   在webapps下面新建一个openclass文件夹,在文件夹下新建一个FirstMpa.html文件,用txt打开此文件,在里面粘贴上下面这段代码,代码放后面,需把下图的三个地方修改成本机的ip地址和tomcat端口名



5、在浏览器中打开FirstMpa.html,效果如下图



//附代码

<!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="http://localhost:8099/arcgis_js_api/library/4.4/dijit/themes/claro/claro.css" />

    <link rel="stylesheet" href="http://localhost:8099/arcgis_js_api/library/4.4/esri/css/main.css" />

    <style>

      html, body, #ui-map-view {

        margin: 0;

        padding: 0;

        width: 100%;

        height: 100%;

      }

    </style>

    <script src="http://localhost:8099/arcgis_js_api/library/4.4/init.js"></script>

    <script>

      var myMap, view;

      require([

        "esri/Basemap",

        "esri/layers/TileLayer",

        "esri/Map",

        "esri/views/MapView",

        "dojo/domReady!"

      ], function (Basemap, TileLayer, Map, MapView){

        // --------------------------------------------------------------------

 
4000
      // If you do not have public Internet access then use the Basemap class

        // and point this URL to your own locally accessible cached service.

        //

        // Otherwise you can just use one of the named hosted ArcGIS services.

        // --------------------------------------------------------------------

        var layer = new TileLayer({

          url: "http://map.geog.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer"

        });

        var customBasemap = new Basemap({

          baseLayers: [layer],

          title: "Custom Basemap",

          id: "myBasemap"

        });

        myMap = new Map({

          basemap: 'osm'

        });

        view = new MapView({

          center: [-111.87, 40.57], // long, lat

          container: "ui-map-view",

          map: myMap,

          zoom: 6

        });

      });

    </script>

  </head>

  <body class="claro">

    <div id="ui-map-view"></div>

  </body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: