if (e.Action == EditGeometry.Action.VextedMoved || e.Action == EditGeometry.Action.VertexAdded)
{
editGeometry.StopEdit();
editGeometry.StartEdit(editGraphic);
}
else if(e.Action == EditGeometry.Action.EditCompleted)
layer.Refresh();
<Grid x:Name="LayoutRoot" Background="White">
<Grid.Resources>
<esri:SimpleFillSymbol x:Key="RedFillSymbol" Fill="#66FF0000" BorderBrush="Red" BorderThickness="2" />
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<esri:Map x:Name="MyMap" WrapAround="True" Background="White">
<esri:ArcGISTiledMapServiceLayer ID="PhysicalTiledLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer"/>
<esri:GraphicsLayer ID="MyLayer" MouseLeftButtonDown="GraphicsLayer_MouseLeftButtonDown" Initialized="GraphicsLayer_Initialized">
<esri:GraphicsLayer.Graphics>
<esri:Graphic Symbol="{StaticResource RedFillSymbol}">
<esri:Polygon >
<esri:Polygon.Rings>
<esri:PointCollection>
<esri:MapPoint X="110.039" Y="-20.303" />
<esri:MapPoint X="132.539" Y="-7.0137" />
<esri:MapPoint X="153.281" Y="-13.923" />
<esri:MapPoint X="162.773" Y="-35.174" />
<esri:MapPoint X="133.594" Y="-43.180" />
<esri:MapPoint X="111.797" Y="-36.032" />
<esri:MapPoint X="110.039" Y="-20.303" />
</esri:PointCollection>
</esri:Polygon.Rings>
</esri:Polygon>
</esri:Graphic>
</esri:GraphicsLayer.Graphics>
</esri:GraphicsLayer>
</esri:Map>
<esri:Map x:Name="MirroredMap" Grid.Column="1" />
</Grid>
EditGeometry editGeometry;
public MainPage()
{
InitializeComponent();
editGeometry = new EditGeometry(MyMap);
editGeometry.IsEnabled = true;
MyMap.ExtentChanged += (s, e) =>
{
MirroredMap.Extent = MyMap.Extent;
};
MyMap.Layers.LayersInitialized += (s, e) =>
{
foreach (var l in MyMap.Layers)
{
if (l is ArcGISTiledMapServiceLayer)
{
MirroredMap.Layers.Add(new ArcGISTiledMapServiceLayer() { ID = l.ID, Url = (l as ArcGISTiledMapServiceLayer).Url });
}
else if (l is GraphicsLayer)
{
var graphicsLayer = new GraphicsLayer() { ID = l.ID };
if ((l as GraphicsLayer).Graphics != null)
{
foreach (var g in (l as GraphicsLayer).Graphics)
{
g.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(g_PropertyChanged);
var clonedGraphic = new Graphic() { Geometry = Geometry.Clone(g.Geometry), Symbol = g.Symbol };
foreach (var item in g.Attributes)
clonedGraphic.Attributes[item.Key] = item.Value;
graphicsLayer.Graphics.Add(clonedGraphic);
}
}
MirroredMap.Layers.Add(graphicsLayer);
}
}
};
}
void g_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == "Geometry")
{
var graphic = sender as Graphic;
var layer = MirroredMap.Layers["MyLayer"] as GraphicsLayer;
var clonedGraphic = layer.Graphics.FirstOrDefault(g => (int) g.Attributes["ObjectID"] == (int) graphic.Attributes["ObjectID"]);
clonedGraphic.Geometry = Geometry.Clone(graphic.Geometry);
}
}
private void GraphicsLayer_MouseLeftButtonDown(object sender, GraphicMouseButtonEventArgs e)
{
editGeometry.StartEdit(e.Graphic);
}
private void GraphicsLayer_Initialized(object sender, EventArgs e)
{
var l = sender as GraphicsLayer;
int i = 0;
foreach (var g in l.Graphics)
{
g.Attributes["ObjectID"] = ++i;
}
}