Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to open a new window from an existing window, which will contain a map with an extent derived from the original window. In other words, the user will zoom to an area in the original window, click a button, then a new window will open with a map set to the zoomed extent. I am using the ArcGIS Javascript API. I have tried several JS/jquery/html methods to make this work, (window.load, ,$window.ready)..but nothing has worked for me. I continue to get an error in my new page saying that 'map' is undefined, and I can see in Firebug that my function to set the new extent based on the extent of the original page runs before the page is fully loaded. I hope I am explaining this problem clearly. Does anyone have any ideas? Thanks,

share|improve this question

1 Answer 1

I continue to get an error in my new page saying that 'map' is undefined

To determine whether the 'map' is undefined error is referring to the "old" map or the "new" map, can you ensure that you've given them unique names?

I can see in Firebug that my function to set the new extent based on the extent of the original page runs before the page is fully loaded

Have you ensured that you're not trying to run code in the "new" map until the page and map are both ready?

See this sample from Esri, which contains:

 //run the init() function when the page is ready
 dojo.addOnLoad(init);

 //run other functions when the map is ready
 dojo.connect(map, 'onLoad', function(theMap) { 
share|improve this answer
    
Thanks for reply...I was actually trying to use the same 'old' map in the new window, with a new extent. If I make a 'new map' object, then I get a 'node is null' error if I do not assign an html id in the new page for the 'old map', or I get a 'NetworkError: 404 'size' parameter is invalid' error if I do assign an HTML id (and assign 'display: none)... Also, if I create a separate 'new map' wouldn't I then need a new init function so that I can also add a legend etc to the new page? –  JasonBK Sep 19 '12 at 13:22
    
@JasonBK I don't believe you'll be able to "transfer" the old map object directly to the new page. Are you able to share your code (perhaps as an attachment) or point us to a sample site? This is hard (for me at least) to debug without being able to see exactly what you're trying to do. –  Stephen Lead Sep 19 '12 at 23:06
    
Thanks, and yes I understand, it will take me some time to make a usable sample. My code is quite long and is using several internal map services. In general though, am I correct to say that to open a new page with a new map, I would essentially need to create a new html and a new javascript file? Otherwise I will have problems with the 'old' map object as I noted above... –  JasonBK Sep 20 '12 at 16:16
    
@JasonBK I'm not an expert on that, sorry (it's probably outside the realm of GIS and more about pure web). I guess what you're asking is whether you can spawn a new page which can access properties which have been set at run-time on an existing page (in your case the properties happen to apply to a map, but really it's just a JS object). –  Stephen Lead Sep 20 '12 at 21:14
    
yes that is what I am asking...ok thanks for reply –  JasonBK Sep 25 '12 at 15:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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