Hi,I'm building a measure tool and I have two maps in different Coordinate projections.I'm using a geometry service to calculate the lengths and areas of geometries that the user draw on the map, and when I use the LengthsAsync mehtod everything works fine for both maps. But when I try to use the AreasAndLengthsAsync method, both the area and lengh comes wrong for both maps.// code to call the AreasAndLengthsAsync Method
GeometryService geometryService = new GeometryService(geometryService.URL);
geometryService.AreasAndLengthsCompleted += this.MeasureFinished;
if (MapSpatialReference == "4326")
{
geometryService.AreasAndLengthsAsync(new List<Graphic>() { draw }, LinearUnit.Meter, LinearUnit.Meter, CalculationType.Geodesic, draw);
System.Windows.MessageBox.Show(this.objetoDedraw.Map.SpatialReference.WKID.ToString());
}
else if (MapSpatialReference == "29194")
{
geometryService.AreasAndLengthsAsync(new List<Graphic>() { draw }, draw);
}
// Code that adds the draw and area text at the map
public void MedicaoTerminada(object sender, AreasAndLengthsEventArgs e)
{
Graphic draw = e.UserState as Graphic;
string area;
if (MapSpatialReference == "4326")
{
area = string.Format("{0} km²", Math.Round(e.Results.Areas.First(), 0));
}
else if (MapSpatialReference == "29194")
{
area = string.Format("{0} m²", Math.Round(e.Results.Areas.First(), 0));
}
Graphic areaDraw = new Graphic();
areaDraw.Geometry = draw.Geometry.Extent.GetCenter();
areaDraw.Symbol = new TextSymbol() { Text = area.ToString(), Foreground = new SolidColorBrush(Colors.Blue) };
(this.objetoDeDesenho.Map.Layers["MeasureGraphicLayer"] as GraphicsLayer).ClearGraphics();
(this.objetoDeDesenho.Map.Layers["MeasureGraphicLayer"] as GraphicsLayer).Graphics.Add(draw);
(this.objetoDeDesenho.Map.Layers["MeasureGraphicLayer"] as GraphicsLayer).Graphics.Add(areaDraw);
}