Select to view content in your preferred language

Change the map extent of the fly

549
1
10-31-2011 07:45 AM
LeoKing
New Contributor
I would like to have a button on my web page that when a user clicks on button it automatically resets teh map's extents to the default extent when map was initially loaded. Has any one done this before?  I think I will need to create a function that calls the map.setExtent. Can someone provide me some sample code?
0 Kudos
1 Reply
by Anonymous User
Not applicable
You have the exact right idea.  When the page loads, you will want to capture the initial extent of the map in a variable (call it initExtent or something).  In a lot of cases, this is set when the map loads and is passed into the map constructor.  This is the case with a lot of the sample apps, including this one:

http://help.arcgis.com/en/webapi/javascript/arcgis/demos/map/map_topo.html

To wire up your button just have the button's onClick() event fire some code that calls map.setExtent and uses the extent that you saved to the variable earlier (initExtent).

Sorry I don't have a code sample, but this should be very straightforward.

Jeff
0 Kudos