Editing using EDITOR

716
1
02-10-2012 07:11 AM
Jitendrudulacaraju
Emerging Contributor
I am trying to add point feature for a featurelayer (point geometry) using the EDITOR in the SL API. This is what I do, see code. I want a sample how this can be done.



 
<Button x:Name="btnAdd" Width="30" Height="30" Margin="120,-125,0,0" ToolTipService.ToolTip="Install a Sign"
                    cal:Click.Command="{Binding EditorAddCommand}"
                    cal:Click.CommandParameter="" 
                    Visibility="{Binding EditButtonsVisibility}"
                    >
                <Button.Content>
                    <Image x:Name="imgMin4" 
                               Source="/CoM.EGIS.Infrastructure;Component/Assets/Images/DrawPoint.png"  
                               Stretch="Fill" HorizontalAlignment="Center" />
                </Button.Content>
            </Button>


 
#region Editor
        private void OnEditorAddCommand(string value)
        {
            EditorAddCommand = SignsEditor.Add;


        }


        private void Editing()
        { 


                   
                    string[] layerids = new string[] { Map.Layers["TrafficSigns"].ToString(),"" };


                    SignsEditor.Map = this.Map;
                    SignsEditor.LayerIDs = layerids;
                    SignsEditor.GeometryServiceUrl = "http://memgisdev4.memphis.ad/ArcGIS/rest/services/Geometry/GeometryServer";


                    SignsEditor.EditorActivated += new EventHandler<Editor.CommandEventArgs>(SignsEditor_EditorActivated);


                    SignsEditor.EditCompleted += (SignsEditor_EditCompleted);


        }




        private void SignsEditor_EditCompleted(object sender, Editor.EditEventArgs e)
        { 
        
        // show the data on the form
            foreach (Editor.Change change in e.Edits)
            {
                if (change.Layer != null && change.Layer is FeatureLayer && change.Graphic != null)
                {
                    FeatureLayer featureLayer = change.Layer as FeatureLayer;
                    //set the form values with a new PUKID which 
                }
            
            }
        
        
        }


        public string LayerID { get; set; }




        private void SignsEditor_EditorActivated(object sender, Editor.CommandEventArgs args)
        {
            OnEditorActivated(args);        
        }
        /// <summary>
        /// Occurs when an editor has been activated.
        /// </summary>
        public event EventHandler<Editor.CommandEventArgs> EditorActivated;


        private void OnEditorActivated(Editor.CommandEventArgs args)
        {
            EventHandler<Editor.CommandEventArgs> handler = EditorActivated;
            if (handler != null)
                handler(this, args);
        }




        private void OnEditCompleted(Editor.EditEventArgs args)
        { 
        
        
        
        }
0 Kudos
1 Reply
JenniferNery
Esri Regular Contributor
You can look at the following SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#EditToolsExplicitSave

   <Grid.Resources>
            <esri:Editor x:Key="MyEditor" 
                         Map="{Binding ElementName=MyMap}" 
                         LayerIDs="ThreatAreas"   
                         GeometryServiceUrl="http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"
                             />
        </Grid.Resources>

 <Button Command="{Binding Add}" Margin="2"  DataContext="{StaticResource MyEditor}"                         
                         Content="Add Polygon">
                        <Button.CommandParameter>
                            <sys:Int32>10301</sys:Int32>
                        </Button.CommandParameter>
                    </Button>


Note that 10301 is a FeatureType from this service: http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer...
0 Kudos