Select to view content in your preferred language

Can i add a Multipoint point to the featurelayer?

2343
2
05-11-2011 12:30 PM
CraigGallant
Deactivated User
I can use the following code to add a single point to the single point feature layer.


private void DrawingSurface_DrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs args)
{

       GraphicsLayer graphicsLayer = MyMap.Layers["DrawGraphicsLayer"] as GraphicsLayer;
       graphicsLayer.ClearGraphics();

       ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
       {
        Geometry = args.Geometry,
              Symbol = MyMarkerSymbol
       };

       graphicsLayer.Graphics.Add(graphic);


       Graphic graphic2 = new Graphic();
       Graphic2.Geometry = graphic.Geometry;


       FeatureLayer fLayer = MyMap.Layers["FeatureLayer"] as FeatureLayer;
       fLayer.Graphics.Add(graphic2);

}


private void btnSave_Click(object sender, RoutedEventArgs e)
{
       FeatureLayer fLayer = MyMap.Layers["FeatureLayer"] as FeatureLayer;
       fLayer.EndSaveEdits += Insert_EndSaveEdits;
       fLayer.SaveEdits();
}


Now I can change the code to store each point i add to the graphic layer to

ESRI.ArcGIS.Client.Geometry.MultiPoint mp = new ESRI.ArcGIS.Client.Geometry.MultiPoint();
point_collection.Add(args.Geometry.Extent.GetCenter());

This give me the collection of my points but i dont know how to save that to a single record in my feature layer. So how do i get my colletion of points to save in the Multipoint feature layer?

Thanks,
Craig
0 Kudos
2 Replies
dotMorten_esri
Esri Notable Contributor
You need to "set" the geometry property on the graphic for the FeatureLayer to detect a change. If you set properties inside the existing PointCollection, the change is not detected. In other words, I think this should trigger it:
myFeature.Geometry = myFeature.Geometry;
(you might have to clone it or change it to null and then back again - can't remember if it detects that this is technically still the same instance)
0 Kudos
CraigGallant
Deactivated User
Ok this is what i tried it looks like it tries to save it but it doesn't.


ESRI.ArcGIS.Client.Geometry.PointCollection point_collection =
new ESRI.ArcGIS.Client.Geometry.PointCollection();

ESRI.ArcGIS.Client.Geometry.MultiPoint mp = new ESRI.ArcGIS.Client.Geometry.MultiPoint();


private void btnSaveEdits_Click(object sender, RoutedEventArgs e)
{
      foreach (var p in point_collection)
      {
            mp.Points.Add(p);       
      }

      Graphic graph = new Graphic();
      graph.Geometry = mp;

      graph.Geometry = graph.Geometry;
           
      FeatureLayer fLayer = MyMap.Layers["FeatureLayer"] as FeatureLayer;
      fLayer.Graphics.Add(graph);

      fLayer.EndSaveEdits += Insert_EndSaveEdits;
      fLayer.SaveEdits();
           
}


Thanks for your help.
Craig
0 Kudos