zoukankan      html  css  js  c++  java
  • 英文帮助翻译

    Create an application using the ArcGIS API for JavaScript 

    Let's walk through a sample application that adds a basemap from ArcGIS.com to the map. View a live version of the application here.

    1. Reference the ArcGIS API for JavaScript(引用ArcGIS API for JavaScript)
      To begin working with the ArcGIS API for JavaScript, add the following script and style sheet tag inside the HTML HEAD element of your HTML page:
      <script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.1" type="text/javascript"></script>
      <link href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/claro/claro.css" rel="stylesheet" type="text/css" >

      The script references the location of the ArcGIS Server JavaScript API files. When new versions of the JavaScript API are released just update the version number to work with the updated version.

      The referenced style sheet is a Dijit theme and is used to add a consistent look and feel to the widgets. There are four themes available: claro, tundra, soria and nihilo. To use one of the alternate themes in your application substitute "tundra" with the theme name.

      <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/tundra/tundra.css">
      
    2. Create the Map(创建底图)
      Add a new script tag to the page, this is where you will add code for working with maps and tasks. First use dojo.require to load any necessary modules(首先使用dojo.require来加载任何需要的模块). Dojo is an open source DHTML toolkit written in JavaScript. The JavaScript API is built on top of Dojo and relies on Dojo for handling core functionality and browser differences(JavaScript API 是建立在Dojo的基础上并且依赖Dojo处理核心的功能和浏览器差异). For more information on the relationship between Dojo and the JavaScript API, see About Dojo.
      <script type="text/javascript">
        dojo.require("esri.map");
      </script>
      

      Next, use dojo.addOnLoad to specify an initialization function that will execute once the HTML is loaded(然后,使用dojo.addOnLoad设置一个初始化函数,这个函数将会在HTML加载后立刻执行). In the initialization function, named init, the map is created and a new basemap layer is added to the map. The basemap layer is a service from ArcGIS.com.

      A new Map is created using esri.Map which is the full reference to the Map class. Class names are always capitalized. The value "mapDiv" is the name of the DIV element that will contain the map.

      Next, the Street Map service, a tiled MapService layer, is initialized using the ArcGISTiledMapServiceLayer constructor. The URL you see is the endpoint for this service. This endpoint is a unique reference to a service that you can generate using Services Directory. Once the layer is initialized, it is added to the map using the map's addLayer method.

      
      <script type="text/javascript">
        dojo.require("esri.map");
        var map;
        function init() {
          map = new esri.Map("mapDiv");
          var basemapURL= "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
          var basemap = new esri.layers.ArcGISTiledMapServiceLayer(basemapURL);
          map.addLayer(basemap);
        }
        dojo.addOnLoad(init);
      </script>
      

      Note:You can browse the ArcGIS.com site for additional online basemap and reference map services or publish your own geographic data as a service using ArcGIS Server.

    3. Define the Page Content(定义页面内容)
      In this step, you will define the BODY section of the HTML page. The BODY section contains everything that will be displayed, in this case a map. The DIV id "mapDiv" references the same variable set in the Map constructor. Note also that a reference to class="claro" is included in the DIV. This references the claro style sheet from the HEAD section. If you use another style, you need to replace "claro" with the new style name.
      <body class="claro">
        <div id="mapDiv" style="900px; height:600px; border:1px solid #000;"></div>
      </body>
      
  • 相关阅读:
    Maven pom.xml文件获取当前时间戳
    maven依赖jdk的tools.jar包坐标怎么依赖
    解决Git问题:git登录账号密码错误remote: Incorrect username or password、如何快速关联/修改Git远程仓库地址、git修改用户名邮箱密码
    浅析Java里的内存分析及常量池加强对Java里字符串的理解
    浅析Java数据结构:稀疏数组的介绍和使用场景
    UmiJS简单介绍及使用UmiJS开发结构浅析
    React基础知识笔记:如何渲染html代码、条件渲染与循环渲染、如何获取动态路由传参、动态设置背景图、umi+dva中全局使用dispatch
    git commit提交时报错husky > pre-commit (node v10.16.3)
    浅析npm报错ENOTFOUND npm ERR! network request to https://npm.***.com/*** failed 及 .npmrc 文件的作用、npm --verbose命令
    浅析为什么说Java中只有值传递
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/1960233.html
Copyright © 2011-2022 走看看