Select to view content in your preferred language

Setting map extent

717
2
Jump to solution
04-22-2012 10:23 PM
AnN
by
Emerging Contributor
Hello,

Is there a way to read the extent from a map and set it (in lat/lon with projection?)

For example:

<esri:Map id="myMap" width="100%" height="100%" mapClick="mapClickHandler(event)"       timeSlider="{myFirstTimeSlider}"       openHandCursorVisible="false" wrapAround180="true">     <esri:Extent id="initExent" xmin="-10854962" ymin="4514317" xmax="-10779136" ymax="4572944">      <esri:SpatialReference wkid="102100"/>     </esri:extent>          <esri:ArcGISDynamicMapServiceLayer id="myDynamicService"               fault="myDynamicService_faultHandler(event)"               load="myTimeLayer_loadHandler(event)"               loadError="myDynamicService_loadErrorHandler(event)"/>       <esri:GraphicsLayer id="clickGraphicsLayer"/>      </esri:Map>


Here, instead of the below codes, that specifies the value for the extent (some number):

<esri:Extent id="initExent" xmin="-10854962" ymin="4514317" xmax="-10779136" ymax="4572944">      <esri:SpatialReference wkid="102100"/>     </esri:extent>


Can I read from the map that I'm loading? Maybe like: myDynamicService.initialExtent.xmin, myDynamicService.initialExtent.xmax, etc...?? The extent for my map is set in lat/lon values, and so the projection also needs to be set. I don't know how to do this, because when I tried, at this time the values are 0.

<esri:Extent id="initExent" xmin="{myDynamicService.initialExtent.xmin}" ymin="{myDynamicService.initialExtent.ymin}" xmax="{myDynamicService.initialExtent.xmax}" ymax="{myDynamicService.initialExtent.}">      <esri:SpatialReference wkid="{myDynamicService.spatialReference}"/>     </esri:extent>



Please help! thank you!!
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
An N,

   The easiest way would be to add that layer first and not specify an extent as the map will get the projection and extent from the first map service added. If that is not the order that you want that layer listed in the map than you just use map.reorderLayer method. You can also do a webService call to that map service and get the initial extent as you were saying and then use webmercatorExtent:

http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/geometry/WebMercatorExtent.html

I don't have any copy and paste code for you, just advice on what you could do as a developer.

Don't forget to click the Mark as answer check on this post and to click the top arrow (promote) as shown below:

View solution in original post

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus
An N,

   The easiest way would be to add that layer first and not specify an extent as the map will get the projection and extent from the first map service added. If that is not the order that you want that layer listed in the map than you just use map.reorderLayer method. You can also do a webService call to that map service and get the initial extent as you were saying and then use webmercatorExtent:

http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/geometry/WebMercatorExtent.html

I don't have any copy and paste code for you, just advice on what you could do as a developer.

Don't forget to click the Mark as answer check on this post and to click the top arrow (promote) as shown below:
0 Kudos
AnN
by
Emerging Contributor
Thank you for the suggestion. 🙂
0 Kudos