Solved

explain javascript code

Posted on 2014-03-18
6
348 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now