inconsistent map extent/center when transitioning between views

753
2
04-29-2014 08:42 AM
TracySchloss
Frequent Contributor
I have an application that starts with a menu where the user selects a county, a category of information and then clicks 'Go' to execute.  The execute does a find on a county layer, zooms to that county and switches from the menu view to the map view.  The first time I zoom to the county, it is not centered to my div.  Or maybe it thinks it is, but it's using a div of 400 x 400, the default, which places it in the upper left of my div.

If I switch back to the menu and pick another county, then it is centered and zoomed correctly.  I've tried all sorts of settings to get it to be properly centered on the first county pick, but no luck at all.  All subsequent selections are always fine.

Why is this?  Does anyone have any other suggestions?  I've combed through the forums trying to include all the tricks that make sense.  My map is already defined as autoResize:false and I have listeners to manually resize and reposition.  This isn't enough to take care of my problem.

Here's my fiddle. 
http://jsfiddle.net/schlot/6ufxj/
0 Kudos
2 Replies
JonathanUihlein
Esri Regular Contributor
I spent some time on this before lunch but did not have much success.
Unfortunately, I don't have much working experience with dojox/mobile.

I see you are using the event: "onAfterTransitionIn"
http://dojotoolkit.org/reference-guide/1.9/dojox/mobile/transition-events.html
This is what I would use as well.

Going to play with this a bit more.
0 Kudos
TracySchloss
Frequent Contributor
Thanks for taking the time to look at this. Some of the threads that describe this issue are using jQuery,  so I'm not sure it matters dojo vs jQuery on what its built with.  As I look around the threads I see several that describe a 'known bug' with the map not knowing how to size or position itself correctly if it's not on the main screen at the start. 

This sounds like something that needs to be addressed in the API itself.  I can't believe I'm the only person who is designing something for mobile that has a menu selection process before a map is shown.  I'm working with state-wide data and it only makes sense to limit the area before I launch the map.
0 Kudos