Parameters
- mapPoint
- The point in map coordinates
Return Value
A point in page coordinates
| Exception | Description |
|---|---|
| System.InvalidOperationException | Mapframe must contain a 2D map |
| System.ArgumentNullException | mapPoint |
| ArcGIS.Core.CalledOnWrongThreadException | This method or property must be called within the lambda passed to QueuedTask.Run. |
{
//Note: Must be on QueuedTask.Run
var pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.BlackRGB, 8);
//Convert the clicked point in client coordinates to the corresponding map coordinates.
//clicked point can be from a Map Tool's HandleMouseDownAsync callback.
//MapViewMouseButtonEventArgs ClientPoint property.
Point clickedPoint;
var clickedMapPoint = MapView.Active.ClientToMap(clickedPoint);
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(string.Format("X: {0} Y: {1} Z: {2}",
mapPoint.X, mapPoint.Y, mapPoint.Z), "Map Coordinates");
//Get the corresponding layout point
var pointOnLayoutFrame = mapFrame.MapToPage(mapPoint);
//Create a point graphic on the Layout.
var cimGraphicElement = new CIMPointGraphic
{
Location = pointOnLayoutFrame,
Symbol = pointSymbol.MakeSymbolReference()
};
//Or use GraphicFactory
var cimGraphicElement2 = GraphicFactory.Instance.CreateSimpleGraphic(
pointOnLayoutFrame, pointSymbol);
ElementFactory.Instance.CreateGraphicElement(layout, cimGraphicElement);
ElementFactory.Instance.CreateGraphicElement(layout, cimGraphicElement2);
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)