Select to view content in your preferred language

Help With DrawTool and Applyedits

739
1
08-11-2010 05:55 AM
AndrewBrown
Deactivated User
Hi, I'm trying to use the drawtool to draw a new polygon then add it to my feature class in SDE via Feature Service.  My feature service map has appropriate permissions to insert new features and I have enabled "Feature Service" on my Map Service.  My feature class coordinate system is GCS_WGS_1984.  I don't want to use EditorToolbar or Template Picker if I can avoid it.

I am using the Drawtool "draw end" event to add each drawn Graphic to a global array whith Push, then I am using a save button to initiate the featureservice.applyedits function passing in the Adds array, and null for updates,deletes.

When I run, I can draw the polygon on the map, and save.  I get a response from the edits complete event with no errors but my features are not in the Feature Class.

Alternatively, if I add an array of Geometries from the Draw End event, and pass an array of Geometries in for the applyedits array, I do get features added, however they do not have any shape.area or shape.length and I can't see them on a preview.  They get an ObjectID assigned.

So, am I using this concept of applyedits correctly or am I assuming it is not as simple as this.  Are there other objects that are required besides a graphic? 

Samples and Documentation all lead you to believe that a feature is nothing more than a graphic. 

Any help would be appreciated... Thank you.

Below is a sample of my code:

<fx:Declarations> 
<esri:SimpleFillSymbol id="sfs"   color="0xFFFFFF"   style="diagonalcross">
    <esri:outline>
<esri:SimpleLineSymbol color="0x00FF00" width="2"/>
    </esri:outline>
</esri:SimpleFillSymbol>

<esri:Extent>
<esri:SpatialReference wkid="102100"/>
</esri:Extent>
<esri:DrawTool id="drawingTool" fillSymbol="{sfs}" graphicsLayer="{newInitiatives}" map="{map}" drawEnd="drawingTool_drawEndHandler(event)"/>
</fx:Declarations>

<fx:Script>
<![CDATA[
  import com.esri.ags.FeatureSet;
  import com.esri.ags.Graphic;
  import com.esri.ags.components.supportClasses.CreateOptions;
  import com.esri.ags.events.DrawEvent;
  import com.esri.ags.events.FeatureLayerEvent;
  import com.esri.ags.geometry.Geometry;
  import com.esri.ags.geometry.Polygon;
  import com.esri.ags.layers.supportClasses.FeatureEditResults;
  import com.esri.ags.layers.supportClasses.FeatureTemplate;
  
  import mx.controls.Alert;
  import mx.events.FlexEvent;
  import mx.messaging.management.Attribute;
  import mx.rpc.AsyncResponder;
  import mx.rpc.events.FaultEvent;
  
  
  internal var drawnFeaturesrray:Array = new Array();
  
  protected function application1_initializeHandler(event:FlexEvent):void
  {

  }

    

  protected function draw_clickHandler(event:MouseEvent):void
  {
   drawingTool.activate(DrawTool.POLYGON);
  }

  protected function drawingTool_drawEndHandler(event:DrawEvent):void
  {       
   drawnFeaturesrray.push(event.graphic);   
  }

  
  protected function save_clickHandler(event:MouseEvent):void
  {
   initiativesFlayer.applyEdits(drawnFeaturesrray,null,null);
  }

  protected function flayer_faultHandler(event:FaultEvent):void
  {
   Alert.show("Fault");
  }
  
  protected function flayer_editsCompleteHandler(event:FeatureLayerEvent):void
  {
   Alert.show("Complete");       
  }

  ]]>
</fx:Script>

<esri:Map id="map">
    <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/"/> 
    <esri:FeatureLayer
id="initiativesFlayer"
editsComplete="flayer_editsCompleteHandler(event)"
fault="flayer_faultHandler(event)"
url="AValidURL"/>
     <esri:GraphicsLayer id="newInitiatives"/>
</esri:Map>

<s:Button id="draw" x="55" y="22" label="draw" click="draw_clickHandler(event)"/>
<s:Button id="save" x="55" y="51" label="save" click="save_clickHandler(event)"/>
Tags (2)
0 Kudos
1 Reply
AndrewBrown
Deactivated User
I was able to fix my problem. Even though my Base Tiled Layer was 102100 and my Feature Service back end data was the same, the polygon was still being drawn in 4326.  Rather than projecting it I just switched to 4326 on the data sources and the polygon was inserted as a feature in SDE just fine.

Anyone else have any thougths on this subject?

Thanks,
Andrew
0 Kudos