<?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:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:esri="http://www.esri.com/2008/ags" creationComplete="application1_creationCompleteHandler(event)"> <fx:Script> <=!=[=C=D=A=T=A=[ import com.esri.ags.Graphic; import com.esri.ags.geometry.Extent; import com.esri.ags.geometry.WebMercatorExtent; import com.esri.ags.geometry.WebMercatorMapPoint; import mx.events.FlexEvent; protected function application1_creationCompleteHandler(event:FlexEvent):void { var newExtent:Extent = new WebMercatorExtent(-179, -14, -64, 25); var graphic:Graphic; graphic = new Graphic(new WebMercatorMapPoint(-179, -14)); layerGraphics.add(graphic); graphic = new Graphic(new WebMercatorMapPoint(-64, 25)); layerGraphics.add(graphic); mapMain.extent = newExtent; if (!mapMain.extent.contains(newExtent)) mapMain.level--; } ]=]=> </fx:Script> <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> </fx:Declarations> <esri:Map id="mapMain" wrapAround180="true"> <esri:ArcGISTiledMapServiceLayer id="layerOceans" alpha="1.0" url="http://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer" visible="true"/> <esri:GraphicsLayer id="layerGraphics" buttonMode="true"/> </esri:Map> </s:Application>
Solved! Go to Solution.
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:esri="http://www.esri.com/2008/ags" creationComplete="application1_creationCompleteHandler(event)">
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:esri="http://www.esri.com/2008/ags" creationComplete="application1_creationCompleteHandler(event)"> <fx:Script> <![CDATA[ import com.esri.ags.Graphic; import com.esri.ags.geometry.Extent; import com.esri.ags.geometry.WebMercatorExtent; import com.esri.ags.geometry.WebMercatorMapPoint; import mx.controls.Alert; import mx.events.FlexEvent; protected function application1_creationCompleteHandler(event:FlexEvent):void { // javascript method - get html document width and height var method:String = "function()" + "{ var obj = new Object();" + "obj.width=document.body.offsetWidth;" + "obj.height=document.body.offsetHeight;" + "return obj; }"; var obj:Object = ExternalInterface.call(method); // create alert message var message:String = "Browser h:" + obj.height + "\nBrowser w:" + obj.width + "\nApp h:" + this.height + "\nApp w:" + this.width + "\nMap h:" + mapMain.height + "\nMap w:" + mapMain.width; Alert.show(message); var newExtent:Extent = new WebMercatorExtent(-179, -14, -64, 25); var graphic:Graphic; graphic = new Graphic(new WebMercatorMapPoint(-179, -14)); layerGraphics.add(graphic); graphic = new Graphic(new WebMercatorMapPoint(-64, 25)); layerGraphics.add(graphic); mapMain.extent = newExtent; if (!mapMain.extent.contains(newExtent)) mapMain.level--; } ]]> </fx:Script> <esri:Map id="mapMain" wrapAround180="true"> <esri:ArcGISTiledMapServiceLayer id="layerOceans" url="http://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer"/> <esri:GraphicsLayer id="layerGraphics"/> </esri:Map> </s:Application>