So I am currently writing an application using the ArcGIS JavaScript API, and I want to access the map object that is held inside of my div from a js module I have. I was thinking it would be a simple JQuery call but it doesn't seem to be the case, as when I try to use map.centerAndZoom(), it states that it is not a member of the object that returned by that call.

Is there anyway to be able to reference the map object that was created in my main index.html elsewhere?

3 Answers 3


After further research, I don't believe it is possible. Instead, I created a global variable to access the map that way.

map = new Map()

instead of

var map = new Map()


I'm not an expert on this, so this may not be best-practise - I'll defer to more expert programmers to come up with a better approach.

But what I usually do is create a single global JSON object and hitch everything off this. eg:

var myObject = {};
myObject.map = new Map("map", {.....});
myObject.layers = {.....};

You can access this object using window.myObject:

  • I ended up just using map = new Map() instead of var map = new Map(). Making it global seemed to do the trick. Jun 10, 2014 at 3:48

On Web Appbuilder created apps a global variable window._viewerMap is created by MapManager.js -> _publishMapEvent

I have not tested this on other JSAPI applications.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.