<?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 Can't tap features on a layer after query in ArcGIS Runtime SDK for iOS Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/can-t-tap-features-on-a-layer-after-query/m-p/1117668#M7220</link>
    <description>&lt;P&gt;I have a feature layer that I can load up, view, and tap without issues. I'm able to see the built-in popup that ArcGIS provides that allows me to edit particular parts of each feature. Here is the code that I'm using.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;let item = AGSPortalItem(portal: self.portal, itemID:"PORTALITEMID")
self.featureTable = AGSServiceFeatureTable(item: item, layerID: 0)
self.waypointFeatureLayer = AGSFeatureLayer(featureTable: self.featureTable)
self.mapView.map?.operationalLayers.add(waypointFeatureLayer!)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I attempt to query the layers, I run into issues. The query works (I only see what I'm looking for), but I can't tap on any features. I get the following error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;Error Domain=com.esri.arcgis.runtime.error Code=2 "Invalid argument." UserInfo={NSLocalizedFailureReason=Unable to run identify on the specified layer.
Layer not identifiable
layer not found in view., NSLocalizedDescription=Invalid argument., Additional Message=Unable to run identify on the specified layer.
Layer not identifiable
layer not found in view.}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I'm using to identify the queried layer is as follows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;guard self.waypointFeatureCollectionLayer != nil else { return }
guard let featureLayer = self.waypointFeatureCollectionLayer.layers.first else {
    fatalError()
}

mapView.identifyLayer(featureLayer, screenPoint: screenPoint, tolerance: 12, returnPopupsOnly: false) { [weak self] (result: AGSIdentifyLayerResult) in
    guard let self = self else { return }
    if let error = result.error {
        log.error(error)
    } else if !result.popups.isEmpty {
        // Unselect the previous feature.
        featureLayer.clearSelection()
        // Select the new feature.
        let features = result.geoElements as? [AGSFeature]
        let selectedFeature = features?.first
        featureLayer.select(selectedFeature!)
        // Display a popup only if it exists.
        let popupsViewController = AGSPopupsViewController(popups: result.popups)
        // Display the popup as a formsheet -- specified for iPads.
        popupsViewController.modalPresentationStyle = .formSheet
        // Present the popup.
        popupsViewController.delegate = self
        self.present(popupsViewController, animated: true)
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the code to load the queried layer is...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;let item = AGSPortalItem(portal: self.portal, itemID: "PORTALITEMID")
self.featureTable = AGSServiceFeatureTable(item: item, layerID: 0)
let queryParams = AGSQueryParameters()
if let primaryUser = CoreDataManager().getPrimaryUser() {
    let clause = "CustomerID=\(primaryUser.id)"
    queryParams.whereClause = clause
    self.featureTable.queryFeatures(with: queryParams) { [weak self] (queryResult: AGSFeatureQueryResult?, error: Error?) in
        if let error = error {
            log.error("Error querying feature table: \(error)")
        } else {
            guard let queryResult = queryResult else { return }
            let featureCollectionTable = AGSFeatureCollectionTable(featureSet: queryResult)
            let featureCollection = AGSFeatureCollection(featureCollectionTables: [featureCollectionTable])
            self?.waypointFeatureCollectionLayer = AGSFeatureCollectionLayer(featureCollection: featureCollection)
            self?.mapView.map?.operationalLayers.add(self?.waypointFeatureCollectionLayer)
        }
    }
} else {
    assertionFailure()
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The one difference I notice is that the queried layer is actually a collection layer. When I run the identifyLayer above, I can find a reference to one layer by using collectionLayer.layers.first (note that this does return a result, so my assumption is it's the layer with my queried features)&lt;/P&gt;&lt;P&gt;Is there a way to make queried layers identifiable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Side note...when I query layers they also show only small black dots, unlike the different types of dots (red/black) on the unqueried layers. I'm not sure if this is something by design or if there is a way to edit how they look after they are queried. The issue with tapping/editing the layers is more important however.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notes:&lt;/P&gt;&lt;P&gt;Using arcgis-runtime-ios 100.11.2&lt;/P&gt;&lt;P&gt;Followed these docs&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/ios/swift/sample-code/feature-collection-layer-query/" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/ios/swift/sample-code/feature-collection-layer-query/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/ios/swift/sample-code/add-features-feature-service/" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/ios/swift/sample-code/add-features-feature-service/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/ios/swift/sample-code/show-popup/" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/ios/swift/sample-code/show-popup/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 17 Nov 2021 14:14:40 GMT</pubDate>
    <dc:creator>ThomasKellough</dc:creator>
    <dc:date>2021-11-17T14:14:40Z</dc:date>
    <item>
      <title>Can't tap features on a layer after query</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/can-t-tap-features-on-a-layer-after-query/m-p/1117668#M7220</link>
      <description>&lt;P&gt;I have a feature layer that I can load up, view, and tap without issues. I'm able to see the built-in popup that ArcGIS provides that allows me to edit particular parts of each feature. Here is the code that I'm using.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;let item = AGSPortalItem(portal: self.portal, itemID:"PORTALITEMID")
self.featureTable = AGSServiceFeatureTable(item: item, layerID: 0)
self.waypointFeatureLayer = AGSFeatureLayer(featureTable: self.featureTable)
self.mapView.map?.operationalLayers.add(waypointFeatureLayer!)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I attempt to query the layers, I run into issues. The query works (I only see what I'm looking for), but I can't tap on any features. I get the following error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;Error Domain=com.esri.arcgis.runtime.error Code=2 "Invalid argument." UserInfo={NSLocalizedFailureReason=Unable to run identify on the specified layer.
Layer not identifiable
layer not found in view., NSLocalizedDescription=Invalid argument., Additional Message=Unable to run identify on the specified layer.
Layer not identifiable
layer not found in view.}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I'm using to identify the queried layer is as follows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;guard self.waypointFeatureCollectionLayer != nil else { return }
guard let featureLayer = self.waypointFeatureCollectionLayer.layers.first else {
    fatalError()
}

mapView.identifyLayer(featureLayer, screenPoint: screenPoint, tolerance: 12, returnPopupsOnly: false) { [weak self] (result: AGSIdentifyLayerResult) in
    guard let self = self else { return }
    if let error = result.error {
        log.error(error)
    } else if !result.popups.isEmpty {
        // Unselect the previous feature.
        featureLayer.clearSelection()
        // Select the new feature.
        let features = result.geoElements as? [AGSFeature]
        let selectedFeature = features?.first
        featureLayer.select(selectedFeature!)
        // Display a popup only if it exists.
        let popupsViewController = AGSPopupsViewController(popups: result.popups)
        // Display the popup as a formsheet -- specified for iPads.
        popupsViewController.modalPresentationStyle = .formSheet
        // Present the popup.
        popupsViewController.delegate = self
        self.present(popupsViewController, animated: true)
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the code to load the queried layer is...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;let item = AGSPortalItem(portal: self.portal, itemID: "PORTALITEMID")
self.featureTable = AGSServiceFeatureTable(item: item, layerID: 0)
let queryParams = AGSQueryParameters()
if let primaryUser = CoreDataManager().getPrimaryUser() {
    let clause = "CustomerID=\(primaryUser.id)"
    queryParams.whereClause = clause
    self.featureTable.queryFeatures(with: queryParams) { [weak self] (queryResult: AGSFeatureQueryResult?, error: Error?) in
        if let error = error {
            log.error("Error querying feature table: \(error)")
        } else {
            guard let queryResult = queryResult else { return }
            let featureCollectionTable = AGSFeatureCollectionTable(featureSet: queryResult)
            let featureCollection = AGSFeatureCollection(featureCollectionTables: [featureCollectionTable])
            self?.waypointFeatureCollectionLayer = AGSFeatureCollectionLayer(featureCollection: featureCollection)
            self?.mapView.map?.operationalLayers.add(self?.waypointFeatureCollectionLayer)
        }
    }
} else {
    assertionFailure()
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The one difference I notice is that the queried layer is actually a collection layer. When I run the identifyLayer above, I can find a reference to one layer by using collectionLayer.layers.first (note that this does return a result, so my assumption is it's the layer with my queried features)&lt;/P&gt;&lt;P&gt;Is there a way to make queried layers identifiable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Side note...when I query layers they also show only small black dots, unlike the different types of dots (red/black) on the unqueried layers. I'm not sure if this is something by design or if there is a way to edit how they look after they are queried. The issue with tapping/editing the layers is more important however.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notes:&lt;/P&gt;&lt;P&gt;Using arcgis-runtime-ios 100.11.2&lt;/P&gt;&lt;P&gt;Followed these docs&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/ios/swift/sample-code/feature-collection-layer-query/" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/ios/swift/sample-code/feature-collection-layer-query/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/ios/swift/sample-code/add-features-feature-service/" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/ios/swift/sample-code/add-features-feature-service/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/ios/swift/sample-code/show-popup/" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/ios/swift/sample-code/show-popup/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 14:14:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/can-t-tap-features-on-a-layer-after-query/m-p/1117668#M7220</guid>
      <dc:creator>ThomasKellough</dc:creator>
      <dc:date>2021-11-17T14:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: Can't tap features on a layer after query</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/can-t-tap-features-on-a-layer-after-query/m-p/1117877#M7221</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I think you're doing too much here. It'll help to know what you're trying to achieve. But in short, this code is great:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;let item = AGSPortalItem(portal: self.portal, itemID:"PORTALITEMID")
self.featureTable = AGSServiceFeatureTable(item: item, layerID: 0)
self.waypointFeatureLayer = AGSFeatureLayer(featureTable: self.featureTable)
self.mapView.map?.operationalLayers.add(waypointFeatureLayer!)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You've just added an AGSFeatureLayer to your map's operational layers which references Layer 0 in the PORTALITEMID service.&lt;/P&gt;&lt;P&gt;So far so good.&lt;/P&gt;&lt;P&gt;The identify code is also good, but you should identify on &lt;STRONG&gt;self.waypointFeatureLayer&lt;/STRONG&gt; instead of &lt;STRONG&gt;self.waypoinyFeatureCollectionLayer.layers.first&lt;/STRONG&gt;. I'll explain why I think that…&lt;/P&gt;&lt;P&gt;Where you're tripping up is that you're creating a new service feature table (even though it's pointing at the same service) and calling query, then creating a NEW layer (in this case an AGSFeatureCollectionLayer) and adding that to the map. That is now a layer that is not connected to the source service, but exists in-memory only. Furthermore, it only contains a subset of the data in the source service at PORTALITEMID (features which match &lt;STRONG&gt;CustomerID=primaryUser.id&lt;/STRONG&gt;).&lt;/P&gt;&lt;P&gt;So, you should still see the original data in&amp;nbsp;&lt;STRONG&gt;self.waypointFeatureLayer&lt;/STRONG&gt;, AND the copy of some of that data in &lt;STRONG&gt;self.waypointFeatureCollectionLayer&lt;/STRONG&gt;&amp;nbsp;which you added when you did the query (see below for why that's a black dot). And yes, it's actually in a sublayer of that AGSFeatureCollectionLayer, but that's not important for right now.&lt;/P&gt;&lt;P&gt;Where I'm lost is how your Identify and Query work together in your use case. What I suspect is that you don't need that additional feature collection layer at all. Simply have &lt;STRONG&gt;self.featureTable&lt;/STRONG&gt; and &lt;STRONG&gt;self.waypointFeatureLayer&lt;/STRONG&gt;. Call Identify on &lt;STRONG&gt;self.waypointFeatureLayer&lt;/STRONG&gt; in response to a user tap event.&lt;/P&gt;&lt;P&gt;If you need to query, just query using the existing &lt;STRONG&gt;self.featureTable&lt;/STRONG&gt;. But what you do with the results might be suspect. I wonder if you might just want to set the &lt;A href="https://developers.arcgis.com/ios/api-reference/interface_a_g_s_feature_layer.html#a4366dae3afbb7a347745bc2c7296a690" target="_self"&gt;&lt;STRONG&gt;definitionExpression&lt;/STRONG&gt;&lt;/A&gt; on &lt;STRONG&gt;self.waypointsFeatureLayer&lt;/STRONG&gt; to "&lt;STRONG&gt;CustomerID=\(primaryUser.id)&lt;/STRONG&gt;". That will limit what's being displayed. Or if you want to highlight an identified feature, perhaps you mean to &lt;A href="https://developers.arcgis.com/ios/api-reference/interface_a_g_s_feature_layer.html#a7197583c0036497a063f2e572ddb4269" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;select&lt;/STRONG&gt;&lt;/A&gt; it in self.waypointsFeatureLayer (there's actually a &lt;A href="https://developers.arcgis.com/ios/api-reference/interface_a_g_s_feature_layer.html#a272bcb19c1d58cfdd8b5fbeb22a07ac8" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;selectWithQuery&lt;/STRONG&gt;&lt;/A&gt; method that could save you a lot of code if that's really what you want to do).&lt;/P&gt;&lt;P&gt;I hope that helps, but I'm flying a bit blind. If you need some more help, I'm happy to dig in a bit but can you explain what your goal is here? I'm pretty certain we can achieve it in a much simpler way.&lt;/P&gt;&lt;P&gt;BTW, the data in &lt;STRONG&gt;self.waypointFeatureCollectionLayer&lt;/STRONG&gt; is a black dot because there is no renderer defined on the layer. And that's expected, because you created a vanilla AGSFeatureCollectionLayer and populated it with raw data from the query. On the other hand, &lt;STRONG&gt;self.waypointFeatureLayer&lt;/STRONG&gt; is able to look at the source service's Layer 0 and read a renderer definition from the JSON metadata it finds there.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 20:19:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/can-t-tap-features-on-a-layer-after-query/m-p/1117877#M7221</guid>
      <dc:creator>Nicholas-Furness</dc:creator>
      <dc:date>2021-11-17T20:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: Can't tap features on a layer after query</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/can-t-tap-features-on-a-layer-after-query/m-p/1118030#M7222</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/176"&gt;@Nicholas-Furness&lt;/a&gt;&amp;nbsp;thanks so much for your detailed explanation.&lt;/P&gt;&lt;P&gt;I apologize for the confusion, I realize I probably didn't explain myself as I wanted. In fact, my Identify would NOT work with my query, which was the reason for this post. It only works without using the query.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In short, I have multiple users submitting features to the same feature layer, but I only want they features that they submitted themselves to be visible, hence the query.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your suggestion of using definitionExpression worked exactly how I wanted though! So I really appreciate the help on that. I'm now able to view only the features that are submitted by the user as well as tap an edit eat feature. Thanks so much again for your prompt and accurate response!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2021 03:42:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/can-t-tap-features-on-a-layer-after-query/m-p/1118030#M7222</guid>
      <dc:creator>ThomasKellough</dc:creator>
      <dc:date>2021-11-18T03:42:47Z</dc:date>
    </item>
  </channel>
</rss>

