Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I want to copy some graphics in GraphicsLayer to FeatureLayer, but it didn't work.
The problem is that it didn't execute SaveEdits(). Mmaybe it didn't complete or failed. It has confused me for a long time.

myfeaturelayer.Initialized += (h, z) =>
            {
                foreach (var x in (mymap.Layers["mygra2"] as GraphicsLayer).Graphics)
                {
                    Graphic g = new Graphic() { Symbol =    LayoutRoot.Resources["BlueMarker"] as Symbol };
                    g.Geometry = Geometry.Clone(x.Geometry);
                    int i = 0;
                    foreach (var k in x.Attributes.Keys)
                    {
                        g.Attributes.Add(k, x.Attributes[k]);
                    }
                    g.Attributes.Add("Id", i);
                    i++;
                    myfeaturelayer.Graphics.Add(g);
                }
                myfeaturelayer.Update();
                myfeaturelayer.UpdateCompleted += (a, b) =>
                {
                    myfeaturelayer.SaveEdits();
                    myfeaturelayer.BeginSaveEdits += (ss1, se1) => {     MessageBox.Show("building"); };
                    myfeaturelayer.EndSaveEdits += (ss, se) =>
                    {
                        mymap.Layers["mygra2"].Opacity = 0.2;
                    };
                    myfeaturelayer.SaveEditsFailed += (s, arg) =>
                    {
                        MessageBox.Show(arg.Error.Message);
                    };
                };
                myfeaturelayer.UpdateFailed += (c, d) => {    MessageBox.Show(d.Error.Message); };
            };
share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.