Select to view content in your preferred language

How to force a map load on a map in a tab not shown?

2649
12
11-30-2011 12:07 PM
CarmenDurham
Frequent Contributor
Please see attached image..

The location and FireGround tabs both contain maps.  The user enters an address and the maps on both tabs need respond to the address entered. 

When the app first opens, the Location tab is active. If an address is entered first, and then make the FireGround tab active, nothing happens because it appears that the Map is not loaded yet.   Is there a way to "force" the Map to load without activating the tab?  I want the fire responders to be able to click on the FireGround tab and it already be zoomed to the entered address with the information they need.

Once the FireGround tab is activated, I can enter an address and it works fine.

Using API 2.0.
Hope I am just missing something simple.
Thanks,
Carmen
Tags (2)
0 Kudos
12 Replies
RobertScheitlin__GISP
MVP Emeritus
Carmen,

   I have to conclude that is is a API extend timing issue... With the code I sent you I occasionally got the symptoms you described. But if you wait long enough an then set extent again it will work fine.
0 Kudos
CarmenDurham
Frequent Contributor
Thank you, Robert, for spending the time to look at this issue. 

Actually, I noticed exactly what you mentioned above in the first code you sent (that was deleted on the forum).  If I opened the app and waited a while (like 2-3 minutes-- too long) and then clicked the 2nd tab, it would be okay. I discovered that accidentally - I had to try it several times to see if I was imagining it.

I will post anything new that develops with support.

Thanks,
Carmen
0 Kudos
CarmenDurham
Frequent Contributor
I worked with technical support which was very helpful.  It is a bug (#NIM076150) and this was the explanation of what was happening from tech support:

"Actually, this has been identified as a bug in the AGS Map.  When the creationpolicy of the viewstack is set to 'all' the map will load immediately but since the map is not visible it's width and height are 0 so the extent is calculated as NaN.  When the viewstack switches to the map the width and height are updated but the extent values remain NaN."

Then, he mentioned something to try...
"Set a fixed width and height on the map  i.e.  then when the viewstack switches to the map reset the width and height to 100% i.e. .  This prevents the extent from ever being calculated as NaN."

Ultimately, his suggestion of using the following in the properties of the container used in the second tab is what worked:  height="{vs.height}" width="{vs.width}"

where "vs" is the id of the viewstack. 

The container I was using is a "bordercontainer" that contained an esriMap as well as some other items.  I set the above properties on the bordercontainer I was using for the second tab.

Now everything works as expected when using the creationpolicy="all" on the viewstack.

Hope this will help someone else.

Thanks,
Carmen
0 Kudos