Solved

explain javascript code

Posted on 2014-03-18
6
365 Views
Last Modified: 2014-03-19
I downloaded sample code - .html file and i am trying to understand it..

Within <head></head> this code of javascript is written....
 <script>
 
      require([
        "esri/map", "esri/layers/ArcGISTiledMapServiceLayer",
        "esri/domUtils", "esri/request",
        "dojo/parser", "dojo/number", "dojo/json", "dojo/dom",
        "dijit/registry", "modules/RasterLayer",

        "dijit/layout/BorderContainer", "dijit/layout/ContentPane",
        "dijit/form/HorizontalSlider", "dojo/domReady!"
      ], function(
        Map, ArcGISTiledMapServiceLayer,
        domUtils, esriRequest,
        parser, number, JSON, dom,
        registry, RasterLayer
      ) {

        //some code
        function mapLoaded() {
//code of maploaded
        }

        function getRasterData() {
       //code
        }

        function setElevation() {
        //code
         }
 
         function supports_canvas() {
                //code
         }
      });
    </script>

Can you please help me understand what it is ?

thanks so much
0
Comment
Question by:ts84zs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 58

Assisted Solution

by:Gary
Gary earned 200 total points
ID: 39937645
Did you read thru
https://developers.arcgis.com/javascript/jstutorials/#step1

Load required modules from the api and set up the required functions is basically all it is doing.
0
 
LVL 15

Accepted Solution

by:
WalkaboutTigger earned 300 total points
ID: 39937685
Essentially, this is JavaScript supporting ArcGIS Server calls.

The "require" function allows modules to be dynamically loaded as needed and specifies what is needed to get them.
See http://www.sitepoint.com/understanding-requirejs-for-effective-javascript-module-loading/ for a very detailed explanation of the "require" function call.

If you would like a detailed explanation of the other ArcGIS JavaScript calls, I would highly recommend looking at
https://developers.arcgis.com/javascript/jshelp/
which explains the various functions and how to use them.
0
 

Author Comment

by:ts84zs
ID: 39937696
But i have not used dojo type of javascript ... so i do not understand the exact javascript  code

Is it executing that function when the page is loaded ?
function(
        Map, ArcGISTiledMapServiceLayer,
        domUtils, esriRequest,
        parser, number, JSON, dom,
        registry, RasterLayer
      ) { //code -mycode }

so mycode section will be executed when the html page will be loaded ?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Expert Comment

by:WalkaboutTigger
ID: 39937818
It is LOADING that code into the browser and instantiating the instances of those calls.  If you are performing code or function calls in the header, they will be executed on page load.  Otherwise, the code won't actually run until it's called.
0
 

Author Comment

by:ts84zs
ID: 39938009
function(
        Map, ArcGISTiledMapServiceLayer,
        domUtils, esriRequest,
        parser, number, JSON, dom,
        registry, RasterLayer
      ) { //code -mycode }



so if i have alert('mymessage' )  ; in mycode section of that code, it will be executed when the page is loaded since it is within <script></script> ?
0
 

Author Comment

by:ts84zs
ID: 39940620
sorry please ignore my previous comment...

i got to know it now...

thanks
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question