【ArcGIS】使用 MXML 或 ActionScript 添加图形Graphics

使用 MXML 或 ActionScript 添加图形Graphics

<?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="使用 MXML 或 ActionScript 添加图形Graphics">  
    <!--  
    文档:  
    https://developers.arcgis.com/en/flex/api-reference/com/esri/ags/Graphic.html  
    https://developers.arcgis.com/en/flex/api-reference/com/esri/ags/SpatialReference.html  
    https://developers.arcgis.com/en/flex/api-reference/com/esri/ags/geometry/Polyline.html  
    https://developers.arcgis.com/en/flex/api-reference/com/esri/ags/geometry/Polygon.html  
    https://developers.arcgis.com/en/flex/api-reference/com/esri/ags/symbols/PictureMarkerSymbol.html  
    https://developers.arcgis.com/en/flex/api-reference/com/esri/ags/symbols/SimpleMarkerSymbol.html  
    https://developers.arcgis.com/en/flex/api-reference/com/esri/ags/symbols/SimpleLineSymbol.html  
    https://developers.arcgis.com/en/flex/api-reference/com/esri/ags/symbols/SimpleFillSymbol.html  
    -->  
  
    <s:layout>  
        <s:VerticalLayout horizontalAlign="center"/>  
    </s:layout>  
  
    <fx:Script>  
        <![CDATA[ 
            import com.esri.ags.SpatialReference; 
            import com.esri.ags.symbols.PictureMarkerSymbol; 
 
            /** 添加标记 **/ 
            private function addSomeMarkers():void 
            { 
                var myGraphicMarker:Graphic = new Graphic(new MapPoint(1447100, 7477200, new SpatialReference(102100)), 
                                                          new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_DIAMOND, 22, 0x009933)); 
                myGraphicMarker.toolTip = "用ActionScript添加标记 SimpleMarkerSymbol"; 
                myGraphicsLayer.add(myGraphicMarker); 
 
                 
                // 图片标记 PictureMarker - embedded image 
                [Embed(source='assets/globe_icon.png')] 
                var picEmbeddedClass:Class; 
                var pictureMarker:PictureMarkerSymbol = new PictureMarkerSymbol(picEmbeddedClass,50,50); 
 
                var myGraphicPic:Graphic = new Graphic(new MapPoint(-411000, 4924000, new SpatialReference(102100))); 
                myGraphicPic.symbol = pictureMarker; 
                myGraphicPic.toolTip = "用ActionScript创建 图片标记 PictureMarkerSymbol"; 
                myGraphicsLayer.add(myGraphicPic); 
 
                 
                var myPolyline:Polyline = new Polyline( 
                    [[ 
                     new MapPoint(-1726185, 9543036), 
                     new MapPoint(34923, 6920940), 
                     new MapPoint(1874303, 6255632), 
                     new MapPoint(1835168, 6255632), 
                     new MapPoint(1913439, 6138225) 
                     ]], new SpatialReference(102100)); 
                var myGraphicLine:Graphic = new Graphic(myPolyline); 
                myGraphicLine.symbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASH, 0xDD2222, 1.0, 4); 
                myGraphicLine.toolTip = "用ActionScript创建 线 SimpleLineSymbol"; 
                myGraphicsLayer.add(myGraphicLine); 
 
                var myPolygon:Polygon = new Polygon( 
                    [[ 
                     new MapPoint(2352491, -1992338), 
                     new MapPoint(2332923, -2461967), 
                     new MapPoint(2646009, -2266288), 
                     new MapPoint(3076503, -2324992), 
                     new MapPoint(3272181, -2520670), 
                     new MapPoint(3506996, -2559806), 
                     new MapPoint(3702675, -3049003), 
                     new MapPoint(3370021, -3675175), 
                     new MapPoint(2763416, -4046965), 
                     new MapPoint(2117676, -4144804), 
                     new MapPoint(1961133, -3890422), 
                     new MapPoint(2000269, -3655607), 
                     new MapPoint(1667615, -3185978), 
                     new MapPoint(1550208, -2422831), 
                     new MapPoint(1334961, -1953202), 
                     new MapPoint(2352491, -1992338) 
                     ]], new SpatialReference(102100)); 
                var myGraphicPolygon:Graphic = new Graphic(); 
                myGraphicPolygon.geometry = myPolygon; 
                myGraphicPolygon.symbol = new SimpleFillSymbol( 
                    SimpleFillSymbol.STYLE_SOLID, // fill style 
                    0xFF0