Solved

explain javascript code

Posted on 2014-03-18
6
360 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
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…

679 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