Having temporary elements on a map is a nice light-weight tool for users to add meaning to what they are looking at. Often, these need to be more sophisticated than simple Map Notes:
Is it on the roadmap to allow developers access to the Pro graphics layer? Or, to an isolated graphics layer that is filled with 3rd party elements?
You can use the AddOverlay method to display a graphic on a 2D map by providing a geometry and a symbol.
This method is available from either the MapView or a MapTool.
The following example displays the vertices of a selected polyline as a graphic.
protected override void OnClick()
//Run on MCT
//get selected polyline
var selectedFeatures = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetSelection();
var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector();
var polyLine = insp.Shape as ArcGIS.Core.Geometry.Polyline;
var multiPointBuilder = new ArcGIS.Core.Geometry.MultipointBuilder();
var markerSymbol = ArcGIS.Desktop.Mapping.SymbolFactory.ConstructMarker(ColorFactory.Red, 11.0, SimpleMarkerStyle.Diamond);
var ptSymbol = SymbolFactory.ConstructPointSymbol(markerSymbol);
var vertexGraphics = MapView.Active.AddOverlay(multiPointBuilder.ToGeometry(), ptSymbol.MakeSymbolReference());
//vertexGraphics.Dispose(); //to clear the overlay
Note that this works differently from the ArcMap graphics container as the graphic is referenced by the returned IDisposable variable. This is usually managed within the lifetime of a tool.
I have added a marker symbol with this code but how to I programmatically label the symbol or create a popup with information on the map? for example, I want to label the point with "Latitude = 38.12345, Longitude = -97.65432"