Select to view content in your preferred language

Editing featurelayer without using map

700
2
10-18-2010 06:46 AM
S_Dee
by
Emerging Contributor
I'm trying to add new features to a Featurelayer. This only seems to work if I get the featurelayer from the map. Is there a way to add features without having to get the layers from the map first?

This is the code I tried, that fails (without any error btw, it just does nothing):

                FeatureLayer layer = new FeatureLayer();
                layer.Url = myLayerUrl;
                layer.AutoSave = false;
                Graphic feature = new Graphic();
                feature.Geometry = myGeometry;
                feature.Attributes.Add("SUMMARY", "hardcoded description 1000");
                layer.Graphics.Add(feature);
                layer.SaveEdits();

I tried calling layer.Inititalize(), but this doesn't seem to do anything either. Maybe I'm missing something here. Is the only way to connect a Featurelayer object to a featureservice to get it from Map.Layers?
I don't want to do this, because not all my tables have to be visible in the map. Also it makes it harder to decouple UI from business objects if i need the Map object everywhere in my application.

Maybe there is another way to get to the featureservice? I can't find any documentation about this.
0 Kudos
2 Replies
dotMorten_esri
Esri Notable Contributor
yes this is possible, but you need to wait for the Initialized event to fire before you do any "editing".
0 Kudos
S_Dee
by
Emerging Contributor
That seems to work. Thank you!
0 Kudos