hi, is it possible to display a xy without creating a feature layer? From an api call I get the xy information, and I want to show where they are located on the map in AGP. But I don’t what to create a feature layer, because the user are going to use the function multiply times, and I don’t want the TOC to be flooded with feature layers.
You can look at this community sample:
It contains code to create a graphics layer (see AddGraphicsLayer.cs) and the code to add a point to that graphic layer (see GraphicCreationTools/PointGraphic.cs).
The ProConcepts document for graphics layers is here: ProConcepts GraphicsLayers · Esri/arcgis-pro-sdk Wiki (github.com)
You can also use an extension method on the MapView class: AddOverlay to add a Symbol (point, line, polygon) to a MapView's grphic overlay. AddOverlay Method (MappingExtensions)—ArcGIS Pro
Here is the documentation on Graphic Overlays for MapView:
ProConcepts Map Exploration · Esri/arcgis-pro-sdk Wiki (github.com)
private IDisposable _graphic = null; //defined elsewhere
// Add point graphic to the overlay at the center of the mapView
// Note: Run within QueuedTask.Run
_graphic = mapView.AddOverlay(mapView.Extent.Center,
SymbolFactory.Instance.ConstructPointSymbol(
ColorFactory.Instance.RedRGB, 40.0, SimpleMarkerStyle.Star).MakeSymbolReference());
// Note: Update graphic using UpdateOverlay
// mapView.UpdateOverlay(_graphic,...);
_graphic.Dispose(); //Removes the graphic