Select to view content in your preferred language

Query all ENC features on a single click

59
1
10 hours ago
Labels (2)
MattAshman96
New Contributor

I have this code that works well for querying the ENC feature that is clicked on. 

 

What I want to do, is be able to display information on every feature that is located at the clicked-on point (common case is you have a buoy with a light, so I want to be able to display the information about the light and the buoy). I would create a custom popup window for this.

 

I would have thought I'd achieve this by iterating through the firstResult.GeoElements list - but that only contains the feature at the top level and not all the features underneath as well.

 

Is there any way to achieve what I am after?

 

Thanks

IReadOnlyList<IdentifyLayerResult> results = await _mapView.IdentifyLayersAsync(e.Position, tolerance, false);
IEnumerable<IdentifyLayerResult> encResults = results.Where(result => result.LayerContent is EncLayer);
IdentifyLayerResult firstResult = encResults.First();
EncLayer containingLayer = (EncLayer)firstResult.LayerContent;
EncFeature encFeature = (EncFeature)firstResult.GeoElements.First();
containingLayer.SelectFeature(encFeature);
StringBuilder sbAttr = new StringBuilder();
foreach (var item in encFeature.Attributes)
{
				sbAttr.AppendLine(item.Key + ":  " + item.Value);
}
CalloutDefinition definition = new CalloutDefinition(encFeature.Description, sbAttr.ToString());
_mapView.ShowCalloutAt(e.Location, definition);
0 Kudos
1 Reply
GKmieliauskas
Esri Regular Contributor

Hi,

As specified in the documentation, your IdentifyLayersAsync method initiates an identify operation on all layers in the view which will return the single visible topmost geoelement per layer only.

There is overload of IdentifyLayersAsync method which allows you to specify the maximum number of geoelements to return per layer:

public Task<IReadOnlyList<IdentifyLayerResult>> IdentifyLayersAsync(Point screenPoint, double tolerance, bool returnPopupsOnly, long maximumResultsPerLayer, CancellationToken cancellationToken)

Or you could try to use spatial query to get all features at the clicked point.

0 Kudos