public SelectionSet GetSelection()
Public Function GetSelection() As SelectionSet
Return Value
The selection in the map represented by the collection of layers and tables and their corresponding object ids.
public SelectionSet GetSelection()
Public Function GetSelection() As SelectionSet
| Exception | Description |
|---|---|
| ArcGIS.Core.CalledOnWrongThreadException | This method or property must be called within the lambda passed to QueuedTask.Run. |
// get the currently selected features in the map var selectedFeatures = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetSelection(); // get the first layer and its corresponding selected feature OIDs var firstSelectionSet = selectedFeatures.ToDictionary().First(); // create an instance of the inspector class var inspector = new ArcGIS.Desktop.Editing.Attributes.Inspector(); // load the selected features into the inspector using a list of object IDs await inspector.LoadAsync(firstSelectionSet.Key, firstSelectionSet.Value);
QueuedTask.Run(() =>
{
// get the currently selected features in the map
var selectedFeatures = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetSelection();
// get the first layer and its corresponding selected feature OIDs
var firstSelectionSet = selectedFeatures.ToDictionary().First();
// create an instance of the inspector class
var inspector = new ArcGIS.Desktop.Editing.Attributes.Inspector();
// load the selected features into the inspector using a list of object IDs
inspector.Load(firstSelectionSet.Key, firstSelectionSet.Value);
//get the value of
var pscode = inspector["STATE_NAME"];
var myGeometry = inspector.Shape;
});
public Task FlashSelectedFeaturesAsync() { return QueuedTask.Run(() => { //Get the active map view. var mapView = MapView.Active; if (mapView == null) return; //Get the selected features from the map and filter out the standalone table selection. //At 2.x //var selectedFeatures = mapView.Map.GetSelection() // .Where(kvp => kvp.Key is BasicFeatureLayer) // .ToDictionary(kvp => (BasicFeatureLayer)kvp.Key, kvp => kvp.Value); ////Flash the collection of features. //mapView.FlashFeature(selectedFeatures); var selectedFeatures = mapView.Map.GetSelection(); //Flash the collection of features. mapView.FlashFeature(selectedFeatures); }); }
Target Platforms: Windows 11, Windows 10