<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: OGC Feature Layer Selection changing randomly in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/ogc-feature-layer-selection-changing-randomly/m-p/1620713#M13579</link>
    <description>&lt;P&gt;Hi Preeti,&lt;/P&gt;&lt;P&gt;Do you have any updates on the status of the issue? Is there any possibility this will be resolved in the next release?&lt;/P&gt;&lt;P&gt;Thank you!&lt;BR /&gt;Tim&lt;/P&gt;</description>
    <pubDate>Wed, 04 Jun 2025 09:34:01 GMT</pubDate>
    <dc:creator>TimScheiber</dc:creator>
    <dc:date>2025-06-04T09:34:01Z</dc:date>
    <item>
      <title>OGC Feature Layer Selection changing randomly</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/ogc-feature-layer-selection-changing-randomly/m-p/1599329#M13415</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have tried to display the &lt;A href="https://demo.ldproxy.net/daraa" target="_self"&gt;Daara&lt;/A&gt;&amp;nbsp;&lt;A href="https://demo.ldproxy.net/daraa/api?f=html#/Discover%20data%20collections/TransportationGroundCrv.getCollection" target="_self"&gt;TransportationGroundCrv Collection&amp;nbsp;&lt;/A&gt;in my WinUI Project. I have a problem where every time I call OgcFeatureCollectionTable.PopulateFromServiceAsync the selection on the layer changes seemingly randomly.&lt;/P&gt;&lt;P&gt;As described in the &lt;A href="https://developers.arcgis.com/net/winui/sample-code/display-ogc-api-collection/" target="_self"&gt;Display OGC API collection&lt;/A&gt; sample, I call PopulateFromServiceAsync on the MapView.NavigationCompleted Event. The Features are populated correctly but the selection somehow changes. This is my code:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var selectedFeatures = await featureLayer.GetSelectedFeaturesAsync();
_logger.LogInformation(" Before: Selected Feature: Count {count}, Attributes {attributes}", selectedFeatures.Count(),
    string.Join(", \n", selectedFeatures.FirstOrDefault()?.Attributes.Select(a =&amp;gt; $"{a.Key}: {a.Value}") ?? []));

await ogcFeatureTable.PopulateFromServiceAsync(wfsVisibleExtentQuery, true, null, ct);

selectedFeatures = await featureLayer.GetSelectedFeaturesAsync();
_logger.LogInformation(" After: Selected Feature: Count {count}, Attributes {attributes}", selectedFeatures.Count(),
    string.Join(", \n", selectedFeatures.FirstOrDefault()?.Attributes.Select(a =&amp;gt; $"{a.Key}: {a.Value}") ?? []));&lt;/LI-CODE&gt;&lt;P&gt;The selected feature before calling PopulateFromServiceAsync is not the same as the selected feature after calling PopulateFromServiceAsync.&lt;/P&gt;&lt;P&gt;I want the feature selection because I display the attributes of the selected feature, and I want the user to be able to see which feature is selected. The selection is implemented using&amp;nbsp;mapView.IdentifyLayerAsync and featureLayer.SelectFeature&lt;/P&gt;&lt;P&gt;The OgcFeatureCollectionTable is initialized as follows:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var ogcFeatureTable = new OgcFeatureCollectionTable(new Uri("https://demo.ldproxy.net/daraa"), "TransportationGroundCrv")
{
    FeatureRequestMode = FeatureRequestMode.ManualCache,
};
new FeatureLayer(ogcFeatureTable)&lt;/LI-CODE&gt;&lt;P&gt;I'm using&amp;nbsp;net8.0 WinUI and&amp;nbsp;Esri.ArcGISRuntime.WinUI 200.6.0&lt;/P&gt;&lt;P&gt;Could this be a bug in the ArcGIS Runtime?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Mar 2025 08:26:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/ogc-feature-layer-selection-changing-randomly/m-p/1599329#M13415</guid>
      <dc:creator>TimScheiber</dc:creator>
      <dc:date>2025-03-26T08:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: OGC Feature Layer Selection changing randomly</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/ogc-feature-layer-selection-changing-randomly/m-p/1599393#M13416</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Are all your selected features in visible map area? From your&amp;nbsp;QueryParameters name I understand what you update only visible map area. So, each time you zoom, pan or etc. some part of selection could be out of visible area, and you get new selection with features inside updated area.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Mar 2025 12:39:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/ogc-feature-layer-selection-changing-randomly/m-p/1599393#M13416</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2025-03-26T12:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: OGC Feature Layer Selection changing randomly</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/ogc-feature-layer-selection-changing-randomly/m-p/1599407#M13417</link>
      <description>&lt;P&gt;Hi, the selected features are inside the visible area. I've attached a GIF that shows how the selection changes when the visible area is updated:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="arcgis_daraa_layer.gif" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/128729i1BE0D05076AC2C29/image-size/medium?v=v2&amp;amp;px=400" role="button" title="arcgis_daraa_layer.gif" alt="arcgis_daraa_layer.gif" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Wed, 26 Mar 2025 13:18:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/ogc-feature-layer-selection-changing-randomly/m-p/1599407#M13417</guid>
      <dc:creator>TimScheiber</dc:creator>
      <dc:date>2025-03-26T13:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: OGC Feature Layer Selection changing randomly</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/ogc-feature-layer-selection-changing-randomly/m-p/1600171#M13423</link>
      <description>&lt;P&gt;I haven't tried your code but I have an idea what might be happening.&lt;BR /&gt;I see you are passing `true` value for `ClearCache` parameter in PopulateServiceAsync, which means all data is cleared from&amp;nbsp;&lt;SPAN&gt;existing table data before loading new results.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I don't know what your parameters are for selecting features, but if you are using ID of the feature to query then it will be a different feature everytime because existing data is getting cleared everytime and new results are loaded.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2025 21:28:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/ogc-feature-layer-selection-changing-randomly/m-p/1600171#M13423</guid>
      <dc:creator>PreetiMaske</dc:creator>
      <dc:date>2025-03-27T21:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: OGC Feature Layer Selection changing randomly</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/ogc-feature-layer-selection-changing-randomly/m-p/1600334#M13426</link>
      <description>&lt;P&gt;The&amp;nbsp;&lt;SPAN&gt;ClearCache parameter changes the selection behavior, but I do not think it should? When I set ClearCache=false, the selection is cleared completely.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want the selection to remain intact after loading new Features from the Service. I do not want the selection to be cleared just because I zoomed in/out on the Map.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;WFS Feature Tables retain their selection after calling PopulateFromServiceAsync, unless ClearCache is set to true and the selected feature is no longer within the current viewpoint.&lt;/P&gt;&lt;P&gt;I've attached a modified &lt;A href="https://developers.arcgis.com/net/winui/sample-code/display-ogc-api-collection/" target="_self"&gt;Display OGC API collection&lt;/A&gt; sample with selection.&lt;/P&gt;&lt;P&gt;You also mentioned selection using and ID of a feature. Is there a way to select a feature on a layer other than FeatureLayer.SelectFeature(Feature) ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Mar 2025 09:52:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/ogc-feature-layer-selection-changing-randomly/m-p/1600334#M13426</guid>
      <dc:creator>TimScheiber</dc:creator>
      <dc:date>2025-03-28T09:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: OGC Feature Layer Selection changing randomly</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/ogc-feature-layer-selection-changing-randomly/m-p/1601939#M13437</link>
      <description>&lt;P&gt;Hi Tim,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the reproducer, we were able to reproduce this. We have logged an issue internally and assigned to the team responsible for this area. We appreciate your feedback. We will continue to investigate this and try to resolve it.&lt;/P&gt;&lt;P&gt;In the meantime, I do have a workaround that you can use, not the best one but will at least unblock youfor now. The workaround below finds the first selected feature and reselects the feature by looking for a matching attribute name `id`. Note my code only selects the first selected feature. You can alter the code to reselect all features as needed. This is just to show the how you we workaround the issue for now. See the updated code below:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;    var currentExtent = MyMapView.VisibleArea.Extent;
    // Create a query based on the current visible extent.
    var visibleExtentQuery = new QueryParameters();
    visibleExtentQuery.Geometry = currentExtent;
    visibleExtentQuery.SpatialRelationship = SpatialRelationship.Intersects;
    // Set a limit of 5000 on the number of returned features per request,
    // because the default on some services could be as low as 10.
    visibleExtentQuery.MaxFeatures = 5000;
    // Get the selected features.
    var selectedFeatures = await _ogcFeatureLayer.GetSelectedFeaturesAsync();
    // Get the id of the first selected feature.
    var firstSelectedFeature = selectedFeatures.FirstOrDefault();
    Int32 id_value = -1;
    if (firstSelectedFeature != null)
    {
        var attributes = firstSelectedFeature.Attributes;
        id_value = Convert.ToInt32(attributes["id"]);
    }
    // Populate the table with the query, leaving existing table entries intact.
    await _featureTable.PopulateFromServiceAsync(visibleExtentQuery, false, null);
    // Find the previously selected feature by its ID. 
    var previously_selected_feature = await _featureTable.QueryFeaturesAsync(new QueryParameters() { WhereClause = "id = " + id_value });
    // Reselect the previously selected features.
    _ogcFeatureLayer.SelectFeatures(previously_selected_feature);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you questions please feel free to reach out.&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;Preeti&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Apr 2025 17:50:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/ogc-feature-layer-selection-changing-randomly/m-p/1601939#M13437</guid>
      <dc:creator>PreetiMaske</dc:creator>
      <dc:date>2025-04-02T17:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: OGC Feature Layer Selection changing randomly</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/ogc-feature-layer-selection-changing-randomly/m-p/1620713#M13579</link>
      <description>&lt;P&gt;Hi Preeti,&lt;/P&gt;&lt;P&gt;Do you have any updates on the status of the issue? Is there any possibility this will be resolved in the next release?&lt;/P&gt;&lt;P&gt;Thank you!&lt;BR /&gt;Tim&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 09:34:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/ogc-feature-layer-selection-changing-randomly/m-p/1620713#M13579</guid>
      <dc:creator>TimScheiber</dc:creator>
      <dc:date>2025-06-04T09:34:01Z</dc:date>
    </item>
  </channel>
</rss>

