window.map versus map - Please explain difference

4561
2
Jump to solution
01-29-2015 10:47 AM
KeithAnderson
New Contributor III

Friends

The ESRI Javascript example below uses Window.grid and Window.map.

They makes a New Map with Window.map and add layers to it with map.addlayer.

Confusing...at least for me. Dojo must be involved.

dgrid | ArcGIS API for JavaScript

Thanks

Keith

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
KellyHutchins
Esri Frequent Contributor

In the samples where you see the window.map or window.[some variable name] the developer is just writing the sample so that the variable is globally accessible.  Basically its attaching the map variable to the window object so you can access it throughout your application.

Here's a link to an article with some more detail:

Global Variables in JavaScript - Snook.ca

And additional reading on global variables in general and why you may want to minimize the use of global variables in your app. See the 'Variable Declarations' section.

Code Conventions for the JavaScript Programming Language

View solution in original post

0 Kudos
2 Replies
KellyHutchins
Esri Frequent Contributor

In the samples where you see the window.map or window.[some variable name] the developer is just writing the sample so that the variable is globally accessible.  Basically its attaching the map variable to the window object so you can access it throughout your application.

Here's a link to an article with some more detail:

Global Variables in JavaScript - Snook.ca

And additional reading on global variables in general and why you may want to minimize the use of global variables in your app. See the 'Variable Declarations' section.

Code Conventions for the JavaScript Programming Language

0 Kudos
KeithAnderson
New Contributor III

Thank you Kelly!

0 Kudos