package { import com.esri.ags.Map; import mx.controls.Alert; import mx.events.FlexEvent; import spark.components.Group; public class BaseMapComponent extends Group { private var _map:Map; public function get map():Map { return _map; } public function set map(value:Map):void { _map = value; } public function BaseMapComponent() { super(); this.addEventListener(FlexEvent.CREATION_COMPLETE, onCreationComplete); } private function onCreationComplete(event:FlexEvent) :void { validateMapPropertyIsSet(); } private function validateMapPropertyIsSet():void { if (map == null) { Alert.show("Map property for (" + this.className + ") is not set. This tool may not work coorectly"); } } } }
<?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" xmlns:Coordinates="Coordinates.*"> <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> </fx:Declarations> <esri:Map id="map"> <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" /> </esri:Map> <Coordinates:Viewer MapControl="{map}" bottom="0" right="0"> </Coordinates:Viewer> </s:Application>
<Coordinates:Viewer MapControl="{myMap}" left="10" right="10" top="10"> </Coordinates:Viewer>
<?xml version="1.0" encoding="utf-8"?> <mx:VBox creationComplete="creationCompleteHandler(event)" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="58" paddingLeft="10" paddingTop="10" paddingBottom="10" paddingRight="10" backgroundColor="#606060"> <fx:Script> <![CDATA[ import com.esri.ags.Map; import com.esri.ags.geometry.MapPoint; import mx.events.FlexEvent; import mx.events.MoveEvent; public var MapControl:Map; [Bindable] public var X:Number = 0; [Bindable] public var Y:Number = 0; protected function creationCompleteHandler(event:FlexEvent):void { this.MapControl.addEventListener(MouseEvent.MOUSE_MOVE, onMapMouseMove); } private function onMapMouseMove(event:MouseEvent):void{ var screenPoint:Point = new Point(event.localX, event.localY); var mapPoint:MapPoint = this.MapControl.toMap(screenPoint); this.X = mapPoint.x; this.Y = mapPoint.y; } ]]> </fx:Script> <s:Label text="{this.X}" id="lblX"/> <s:Label text="{this.Y}" id="lblY"/> </mx:VBox>
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.