Select to view content in your preferred language

MapTool that selects only one feature

1074
4
Jump to solution
07-21-2022 12:58 AM
KhaledAliMoh
Occasional Contributor

How to create a map tool that selects only one feature when click on a point with a tolerance.

For now I can use ActiveMapView.SelectFeatures(geometry), but this method can select multiple feature layer or multiple feature in a layer. 

var selection = ActiveMapView.SelectFeatures(clickedPoint, method: SelectionCombinationMethod.New);
0 Kudos
1 Solution

Accepted Solutions
KhaledAliMoh
Occasional Contributor

I don't know what you mean by 

// this statment
oids = oid;

 

However I was able to get the answer from the method you have mentioned GetFeatures(geometry).

Thank you for your help.

View solution in original post

0 Kudos
4 Replies
CharlesMacleod
Esri Regular Contributor

You most likely want FeatureLayer Select(...). https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic11392.html 

Something like:

 var sqf = new SpatialQueryFilter() {
   FilterGeometry = clickedPoint,
   SpatialRelationship = SpatialRelationship.Intersects,//change as needed
   WhereClause = "Optional SQL whereclause here",
   SubFields = "*"
 };
 var selection = featLayer.Select(sqf);

 

0 Kudos
KhaledAliMoh
Occasional Contributor

How can I get the featureLayer ?

0 Kudos
DavidMrázek
Frequent Contributor

What about this:

 var features = mapView.GetFeatures(point);
                if (features.ContainsKey(layer))
                {
                    var tag = features.FirstOrDefault(t => t.Key == layer);
                    var oids = tag.Value;
                    foreach (var oid in oids)
                    {
                        oids = oid;
                    }
var filter = new QueryFilter
            {
                WhereClause = " OBJECTID = " + oid
            };
 var select = layer.Select(filter);
0 Kudos
KhaledAliMoh
Occasional Contributor

I don't know what you mean by 

// this statment
oids = oid;

 

However I was able to get the answer from the method you have mentioned GetFeatures(geometry).

Thank you for your help.

0 Kudos