setExtent: need to execute twice

678
1
06-11-2012 03:17 PM
AndyStewart1
New Contributor III
We have a function for zooming to a saved extent that only works when executed a second time:

function setMapExtentESRI(xMin, yMin, xMax, yMax) {
var sr = new esri.SpatialReference({wkid: 1337}); /* where 1337 is a well-known ID */
var extent = new esri.geometry.Extent(xMin, yMin, xMax, yMax, sr); /*
esrimap.setExtent(extent);
}


The first time this exact code is executed, the map moves to the correct extent but disappears. The second time this code is executed with the same parameters, with no other code executing in the meantime, the map appears at that extent.

Running API version 2.5.  Tried 2.7 with the same results.
0 Kudos
1 Reply
by Anonymous User
Not applicable
Hi Don, can you post more of your code?  I tested your method with 2.7 and it seems to be working fine.  Or could you provide more information about the map services you are using?
0 Kudos