Advertisement
Guest User

TestWidget

a guest
Oct 16th, 2011
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!--
  3. ////////////////////////////////////////////////////////////////////////////////
  4. //
  5. // Copyright (c) 2010 ESRI
  6. //
  7. // All rights reserved under the copyright laws of the United States.
  8. // You may freely redistribute and use this software, with or
  9. // without modification, provided you include the original copyright
  10. // and use restrictions.  See use restrictions in the file:
  11. // <install location>/License.txt
  12. //
  13. ////////////////////////////////////////////////////////////////////////////////
  14. -->
  15. <viewer:BaseWidget xmlns:esri="http://www.esri.com/2008/ags"
  16.                    xmlns:fx="http://ns.adobe.com/mxml/2009"
  17.                    xmlns:s="library://ns.adobe.com/flex/spark"
  18.                    xmlns:mx="library://ns.adobe.com/flex/mx"
  19.                    xmlns:mxeffects="com.adobe.ac.mxeffects.*"
  20.                    xmlns:flash="flash.text.*"
  21.                    xmlns:viewer="com.esri.viewer.*"
  22.                    xmlns:widgets="widgets.*"
  23.                    x="600" y="300"
  24.                    initialize="basewidget1_initializeHandler(event)"
  25.                    >
  26.     <fx:Script>
  27.         <![CDATA[
  28.             import com.esri.ags.Graphic;
  29.             import com.esri.ags.geometry.Geometry;
  30.             import com.esri.ags.geometry.MapPoint;
  31.             import com.esri.ags.layers.GraphicsLayer;
  32.             import com.esri.ags.symbols.*;
  33.            
  34.             import mx.controls.Alert;
  35.             import mx.events.FlexEvent;
  36.            
  37.             import spark.components.Button;
  38.            
  39.            
  40.            
  41.             [Bindable]
  42.             private var graphicsLayer:GraphicsLayer;
  43.            
  44.             private var myGraphic:Graphic = new Graphic();
  45.             private var geom:Geometry = new Geometry();
  46.             var mycs:CustomSymbol;
  47.            
  48.        
  49.            
  50.            
  51.             protected function basewidget1_initializeHandler(event:FlexEvent):void
  52.             {
  53.                 // TODO Auto-generated method stub
  54.                 graphicsLayer = new GraphicsLayer();
  55.                 graphicsLayer.name = "testLayer";
  56.                 map.addLayer(graphicsLayer);
  57.                 map.addEventListener(MouseEvent.CLICK,mapMouseClickhandler);
  58.             }
  59.    
  60.        
  61.             private function mapMouseClickhandler(event:MouseEvent):void {
  62.                
  63.                 const mapPoint:MapPoint = map.toMapFromStage(event.stageX, event.stageY);
  64.                 mapPoint.spatialReference = map.spatialReference;
  65.                 geom= mapPoint;
  66.                
  67.                 mycs= new CustomSymbol();
  68.                 myGraphic = new Graphic(geom,mycs);
  69.                 graphicsLayer.add(myGraphic);
  70.            
  71.            
  72.             }
  73.  
  74.         ]]>
  75.     </fx:Script>
  76.    
  77.    
  78.     <fx:Declarations>
  79.        
  80.     </fx:Declarations>
  81.    
  82.     <viewer:WidgetTemplate id="wTemplate"
  83.                            width="420" height="300"
  84.                            minHeight="300"
  85.                            minWidth="420">
  86.        
  87.     <s:Label text="click on the map" />
  88.            
  89.    
  90.     </viewer:WidgetTemplate>
  91. </viewer:BaseWidget>
  92.  
  93.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement