Select to view content in your preferred language

Can we create a graphic and add to any feature layer

1960
1
05-19-2011 12:17 PM
MuralidharMoka
Emerging Contributor
I created a polygonon a graphic layer using DrawObject.
I want to add it to some featureLayer.
is it possible ?

eg
featurelayer f= MyMap.FeatureLayer["myfeaturelayer'] as FeatureLayer;

Graphic g=new Graphic();
g.symbol=MySimpleFillSymbol;
g.geometry= args.geometry;

f.Graphics.Add(g)
f.SaveEdits();
I tried this and it does not allow to do this.

//is there any other way to do this.
0 Kudos
1 Reply
JenniferNery
Esri Regular Contributor
You should be able to do this. Is your FeatureLayer already Initialized? What error message are you getting?

You don't need to set Graphic.Symbol though but you may need to give it default values for the attributes. Usually you want to use Editor.Add or TemplatePicker to add the simplified feature with default attributes. But if you are using Draw class, you can go through the LayerInfo.Fields to know what default attribute value to give the feature. See Post# 4 in this thread: http://forums.arcgis.com/threads/18542-How-to-save-the-feature-in-featurelayer-back-to-geometry-serv...
0 Kudos