The first sample program for creating ArcGIS API for JavaScript

Source: Internet
Author: User

In the previous blog, we have described how to build an ArcGIS API for JavaScript development environment, if you have not yet set up a development environment, refer to the blog: http://blog.csdn.net/zdw_wym/article/details/48678913.

If the development environment is set up, today we continue to build our first ArcGIS API for JavaScript application.

The following first paste the code out and copy it into the new HTML page in VS2012.

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

Run as follows:


Next we focus on the following JS code, which uses the AMD approach:

      <script type= "Text/javascript";
      & nbsp       VAR map;
              require (["esri/map "," dojo/domready! "], function (map) {
                  map = new map ("map", {
              &NBSP ;       Basemap: "Topo",
                      cent ER: [118.932036047149, 32.09141405],
                      Zoom:
                 });
             });
     </script>

Use ESRI's preferences when naming parameters in the Require callback function. In the above code, a reference to the Esri/map resource is provided, and then in the internal anonymous function, a map preference is provided, and each resource referenced in the Require function has a corresponding parameter to provide access to the resource object.

The outdated wording is as follows:

    <script type= "Text/javascript";
           dojo.require ("esri.map ");
           function init () {
    & nbsp          var map = new ESRI. Map ("Map", {
                    Basemap: "Topo",
    &N Bsp               Center: [118.932036047149, 32.09141405],
        & nbsp           ZOOM:10
             });
         }
         dojo.ready ( Init );
    &NBSP;</SCRIPT>

Dojo.require has not been recommended, the official document is recommended to use require, as for the module name delimiter is only a grammar requirements.


The first sample program for creating ArcGIS API for JavaScript

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.