Select to view content in your preferred language

Editing Graphics Layer

849
3
08-10-2010 08:50 PM
MatthewReines
New Contributor
When I use the Silverlight Client.Editor and begin an Edit using

EditVertices.Execute(graphic.Geometry)

How do I get the commit and retrieve edits made programatically?

I try listening to the PointCollection of the (Polygon or Polyline) graphic, but it never changes as far as I can tell.

This seems simple, like I'm missing something fundamental -- any help here?
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
You can look at this sample for guide: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#EditToolsExplicitSave

You can also listen to the Editor's EditCompleted event and do the following to save edits:
        void editor_EditCompleted(object sender, Editor.EditEventArgs e)
        {
            foreach (var edit in e.Edits)
            {
                if (e.Action== Editor.EditAction.EditVertices && 
                    edit.Layer is FeatureLayer)
                {
                    (edit.Layer as FeatureLayer).SaveEdits();
                }
            }
        }


edit also includes edit.Graphic so you will know which graphic was modified.

Also, this is incorrect:

EditVertices.Execute(graphic.Geometry)


EditVertices command can accept graphic as parameter but not its geometry.

Jennifer
0 Kudos
MatthewReines
New Contributor
Jennifer,

Thank you for the quick response. Unfortunately maybe my question was a little off.

First, I misstated how EditVertices was instigated, its done using the graphic, not the graphic.Geometry. Thanks for ointing that out.

Also, in both your response and the sample, which I was familiar with, the code refers to getting the edits from a feature layer, which of course has the SaveEdits method. I'm trying to do essentially the same thing with a graphics layer that is NOT a feature layer. The layer type I'm actually wanting to edit is based on the KmlLayer examples found elsewhere in these forums and is not based on FeatureLayer.

Maybe that is the problem, I should be using a feature layer even though I do not get them directly  from ArcServer? Or how to get the .SaveEdits functionality from a GraphicsLayer without the cast to FeatureLayer.
0 Kudos
JenniferNery
Esri Regular Contributor
In that case, you can supply the graphic maybe from MouseLeftButtonDown event, and then EditVertices.Execute(e.Graphic).

I believe we pulled support for KmlLayer at this time for v2.0. But just the same, you can look at this thread for saving graphics layer:http://forums.arcgis.com/threads/1861-Saving-a-graphics-layer

Jennifer
0 Kudos