<esri:Map id="map"> <esri:extent> <esri:Extent id="initialExtent" xmin="-13001000" ymin="3292000" xmax="-8812000" ymax="6154000"> <esri:SpatialReference wkid="102100"/> </esri:Extent> </esri:extent> <esri:ArcGISTiledMapServiceLayer id="tiledlayer" url="<someurl>" </esri:ArcGISTiledMapServiceLayer> </esri:Map>
Think of it this way. Say you've set the extent so the X difference is 100,000 units. You've set the size of your map to be 1 unit wide, which makes the scale of your displayed map 1:100,000. If the tiled layer is set up with the Web mercator standard levels of detail at 1:144,447.638572 and 1:72,223.819286, the extent of the map will have to change to fit one of those scale. When you're using tiled layers, you cannot set arbitary scales, but have to use the pre-determined scales. If you're using only dynamic layers, you can set any scale you'd like.
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:esri="http://www.esri.com/2008/ags" pageTitle="Map Extent and Mouse Coordinates"> <!-- The current extent of the map is available directly through myMap.extent. Similarly, the current scale is myMap.scale. Other properties easily accessible is myMap. To get the current coordinates of the mouse cursor, you can add an event listener for "MOUSE_MOVE" on the map. In the listener you can access the current stage location using stageX and stageY. Then use the toMapFromStage method to easily get those stage coordinates into map coordinates. --> <fx:Script> <![CDATA[ import com.esri.ags.events.ExtentEvent; import com.esri.ags.geometry.Extent; import com.esri.ags.geometry.MapPoint; import com.esri.ags.utils.WebMercatorUtil; // when mouse (cursor) is on the map ... private function loadHandler():void { myMap.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); } // ... show coordinates of current (mouse) location private function mouseMoveHandler(event:MouseEvent):void { const mapPoint:MapPoint = myMap.toMapFromStage(event.stageX, event.stageY); const latlong:MapPoint = WebMercatorUtil.webMercatorToGeographic(mapPoint) as MapPoint; mousecoords.text = "x,y is " + mapPoint.x.toFixed(0) + "," + mapPoint.y.toFixed(0) + " and Lat/Long is: " + latlong.y.toFixed(6) + " / " + latlong.x.toFixed(6); } // convert current projected extent to geographic and show as such protected function showExtentInGeographic(extent:Extent):String { const geoExtent:Extent = WebMercatorUtil.webMercatorToGeographic(myMap.extent) as Extent; // return geoExtent.toString() + ".." ; return " " + geoExtent.xmin.toFixed(6) + ", " + geoExtent.ymin.toFixed(6) + ", " + geoExtent.xmax.toFixed(6) + ", " + geoExtent.ymax.toFixed(6) + " (wkid: " + geoExtent.spatialReference.wkid + ")"; } ]]> </fx:Script> <fx:Declarations> <esri:Extent id="initialExtent" xmin="-13001000" ymin="3292000" xmax="-8812000" ymax="6154000"> <esri:SpatialReference wkid="102100"/> </esri:Extent> </fx:Declarations> <s:layout> <s:VerticalLayout paddingTop="6"/> </s:layout> <s:HGroup> <s:Label fontWeight="bold" text="Current map extent:"/> <s:RichEditableText editable="false" text='xmin="{myMap.extent.xmin.toFixed(0)}" ymin="{myMap.extent.ymin.toFixed(0)}" xmax="{myMap.extent.xmax.toFixed(0)}" ymax="{myMap.extent.ymax.toFixed(0)}" (wkid="{myMap.spatialReference.wkid}")'/> </s:HGroup> <s:HGroup> <s:Label fontWeight="bold" text="Current map extent (in geographic):"/> <s:RichEditableText editable="false" text="{showExtentInGeographic(myMap.extent)}"/> </s:HGroup> <s:HGroup> <s:Label fontWeight="bold" text="Current Mouse Coordinates:"/> <s:RichEditableText id="mousecoords" editable="false" text="Move the mouse over the map to see its current coordinates..."/> </s:HGroup> <s:HGroup> <s:Label fontWeight="bold" text="Current map scale is"/> <s:RichEditableText editable="false" text="1:{myMap.scale.toFixed(0)} (level {myMap.level})"/> </s:HGroup> <esri:Map id="myMap" load="loadHandler()" extent="{initialExtent}"> <!-- <esri:extent> <esri:Extent xmin="3035000" ymin="4305000" xmax="3475000" ymax="10125000"> <esri:SpatialReference wkid="102100"/> </esri:Extent> </esri:extent>--> <!-- <esri:ArcGISDynamicMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/> --> <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/> </esri:Map> </s:Application>