private void ApplyButton_Click(object sender, RoutedEventArgs e)
{
ClearGraphicsLayers();
OutJsonTextBox.Text = "";
try
{
// Convert from Geometry to ArcGIS REST geometry json
Geometry geometry = Geometry.FromJson(InJsonTextBox.Text);
Graphic graphic = new Graphic();
if (geometry is MapPoint)
graphic.Symbol = LayoutRoot.Resources["RedMarkerSymbol"] as SimpleMarkerSymbol;
else if (geometry is Polyline)
graphic.Symbol = LayoutRoot.Resources["RedLineSymbol"] as SimpleLineSymbol;
else if (geometry is Polygon)
graphic.Symbol = LayoutRoot.Resources["RedFillSymbol"] as SimpleFillSymbol;
else if (geometry is Envelope)
graphic.Symbol = LayoutRoot.Resources["RedFillSymbol"] as SimpleFillSymbol;
if (graphic.Symbol != null)
{
graphic.Geometry = geometry;
_myFromJsonGraphicsLayer.Graphics.Add(graphic);
}
}
catch
{
MessageBox.Show("Unable to convert json into geometry");
}
}