Editing Graphics Layer

1869
2
Jump to solution
05-28-2012 03:19 PM
Labels (1)
ShaunWeston
Occasional Contributor
I'm just trying to develop a toolbar that enables drawing and editing of the drawings. I'm using this Graphics>Interactively sample, which is really good apart from two things
[ATTACH=CONFIG]14692[/ATTACH]

- After you create a graphic, then edit where it is located, then try and edit another graphic, the first graphic reverts back to where it originally was. So, I'm just trying to figure out how to save the graphic in it's new position once it has been edited. I figure it's editing this function some how?
private void GraphicsLayer_MouseLeftButtonUp(object sender, GraphicMouseButtonEventArgs e)         {             if (EnableEditVerticesScaleRotate.IsChecked.Value)  {                 Editor editor = LayoutRoot.Resources["MyEditor"] as Editor;                 if (e.Graphic != null && !(e.Graphic.Geometry is ESRI.ArcGIS.Client.Geometry.MapPoint))   {                     editor.EditVertices.Execute(e.Graphic);                 }             }         }


- I was wondering how to go about adding text into a graphics layer. So I want a user to be able to select a point on a map and then this would bring up a textbox where they can type in some info.

Any help on these two things would be awesome 🙂
0 Kudos
1 Solution

Accepted Solutions
KerrieScholefield
Occasional Contributor
Hi,

Instead of using Editor.EditVertices you could use EditGeometry Class so that you can call StopEdit() in code behind.
A sample using the EditGeometry Class can be found in the Sample Application under Editing > Edit Tools > Edit Tools Geometry and the documentation can be found below:
http://resourcesbeta.arcgis.com/en/help/runtime-wpf/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Edi...


An editable TextBox can be added to an ElementLayer.  A sample showing how to add an ElementLayer in .xaml can be found under  Mapping > Dynamic Map Layers > Element Layer

The code below shows how an ElementLayer with an editable TextBox can be created in code behind when the Map.MouseClick event is fired.

<esri:Map x:Name="MyMap" MouseClick="MyMap_MouseClick">             <esri:ArcGISTiledMapServiceLayer ID="PhysicalTiledLayer"                        Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>               <esri:ElementLayer ID="MyElementLayer"/>                     </esri:Map>


      private void MyMap_MouseClick(object sender, Map.MouseEventArgs e)         {             ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint = e.MapPoint;             ElementLayer elementLayer = MyMap.Layers["MyElementLayer"] as ElementLayer;                    TextBox textBox = new TextBox();             textBox.Text = "Editable text";                textBox.SetValue(ElementLayer.EnvelopeProperty, new Envelope(clickPoint.X, clickPoint.Y, clickPoint.X, clickPoint.Y));             elementLayer.Children.Add(textBox);             MyMap.Layers.Add(elementLayer);         }


Cheers,

Kerrie

View solution in original post

0 Kudos
2 Replies
KerrieScholefield
Occasional Contributor
Hi,

Instead of using Editor.EditVertices you could use EditGeometry Class so that you can call StopEdit() in code behind.
A sample using the EditGeometry Class can be found in the Sample Application under Editing > Edit Tools > Edit Tools Geometry and the documentation can be found below:
http://resourcesbeta.arcgis.com/en/help/runtime-wpf/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Edi...


An editable TextBox can be added to an ElementLayer.  A sample showing how to add an ElementLayer in .xaml can be found under  Mapping > Dynamic Map Layers > Element Layer

The code below shows how an ElementLayer with an editable TextBox can be created in code behind when the Map.MouseClick event is fired.

<esri:Map x:Name="MyMap" MouseClick="MyMap_MouseClick">             <esri:ArcGISTiledMapServiceLayer ID="PhysicalTiledLayer"                        Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>               <esri:ElementLayer ID="MyElementLayer"/>                     </esri:Map>


      private void MyMap_MouseClick(object sender, Map.MouseEventArgs e)         {             ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint = e.MapPoint;             ElementLayer elementLayer = MyMap.Layers["MyElementLayer"] as ElementLayer;                    TextBox textBox = new TextBox();             textBox.Text = "Editable text";                textBox.SetValue(ElementLayer.EnvelopeProperty, new Envelope(clickPoint.X, clickPoint.Y, clickPoint.X, clickPoint.Y));             elementLayer.Children.Add(textBox);             MyMap.Layers.Add(elementLayer);         }


Cheers,

Kerrie
0 Kudos
ShaunWeston
Occasional Contributor
Hi Kerrie,

Thanks for that info, I managed to implement the two suggestions successfully 🙂
0 Kudos