?
Solved

explain javascript code

Posted on 2014-03-18
6
Medium Priority
?
372 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 800 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 1200 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
Technology Partners: 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

718 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