Hi,
Yes, there's a LocalGeometryService in the ESRI.ArcGIS.Client.Local namespace which should be used to provide the URL property to the GeometryService task in the ESRI.ArcGIS.Client.Tasks namespace. For example the C# code below will help you achieve your goal.
// Create a new LocalGeometryService
LocalGeometryService localGeometryService = new LocalGeometryService();
// Start the LocalGeometryService (we'll do it synchronously because it starts quickly)
localGeometryService.Start();
// Create a GeometryTask and assign the URL from the LocalGeometryService
GeometryService geometryTask = new GeometryService()
{
Url = localGeometryService.UrlGeometryService
};
// Use the Geometry task...
// e.g. geometryTask.Project(...);
MapPoint mapPoint = new MapPoint(-0.126, 51.500, new SpatialReference(4326));
geometryTask.ProjectCompleted += (senderObject, graphicsEventArgs) =>
{
Graphic resultGraphic = graphicsEventArgs.Results[0];
if (resultGraphic.Geometry.Extent != null)
{
resultGraphic.Symbol = new SimpleMarkerSymbol()
{
Color = new SolidColorBrush(Colors.Red),
Size = 14,
Style = SimpleMarkerSymbol.SimpleMarkerStyle.Circle
};
MapPoint resultMapPoint = resultGraphic.Geometry as MapPoint;
resultGraphic.Attributes.Add("Output_CoordinateX", resultMapPoint.X);
resultGraphic.Attributes.Add("Output_CoordinateY", resultMapPoint.Y);
GraphicsLayer graphicsLayer = new GraphicsLayer();
graphicsLayer.Graphics.Add(resultGraphic);
MapControl.Layers.Add(graphicsLayer);
MapControl.PanTo(resultGraphic.Geometry);
}
else
{
MessageBox.Show("Invalid input coordinate, unable to project.");
}
};
geometryTask.ProjectAsync(new List<Graphic>() { new Graphic() { Geometry = mapPoint } }, new SpatialReference(3857));
The LocalGeometryServiceTask class is an extension to the GeometryService task and contains two convenience methods for initializing a Geometry task with a LocalGeometryService so in the example above the first few lines could be abbreviated to:
GeometryService geometryTask = new GeometryService();
LocalGeometryService localGeometryService = LocalGeometryServiceTask.InitializeWithLocalService(geometryTask);
Many thanks for your feedback.
Cheers
Mike