Solved

explain javascript code

Posted on 2014-03-18
6
356 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
  • 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
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…

786 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