Select to view content in your preferred language

Identify operation for one of the layers does not work

2371
12
Jump to solution
07-29-2021 03:55 AM
bferrao
New Contributor

I am facing an issue in identify operation for one of the layers(Layer name is Service) in a map service.

Map is loaded on the mapview using the map service (AGSArcGISMapImageLayer)

        let basemap = AGSBasemap.streets()

        let map = AGSMap(basemap: basemap)

        

        // Map image layer.

        let mapImageLayer = AGSArcGISMapImageLayer(url: URL(string: "map service url”)!)

        // mapImageLayer.credential = AGSCredential(user: username, password: password)

        

        mapImageLayer.load { [weak mapImageLayer] (error: Error?) in

        }

        map.operationalLayers.add(mapImageLayer)

        

        // Assign map to the map view.

        mapView.map = map

 

        // Add self as the touch delegate for the map view.

        mapView.touchDelegate = self


Once the map is loaded, I zoom in to the "Service" feature so that it is visible. On tapping on the feature, the identify operation is performed:

// MARK: - AGSGeoViewTouchDelegate

func geoView(_ geoView: AGSGeoView, didTapAtScreenPoint screenPoint: CGPoint, mapPoint: AGSPoint) {

        // Get the geoElements for all layers present at the tapped point.

        self.identifyLayers(screenPoint)

    }

    

    // MARK: - Identify layers

    private func identifyLayers(_ screen: CGPoint) {

        self.mapView.identifyLayers(atScreenPoint: screen, tolerance: 22, returnPopupsOnly: false, maximumResultsPerLayer: 10) { (results: [AGSIdentifyLayerResult]?, error: Error?) in

                        

            if let error = error {

                self.presentAlert(error: error)

            } else {

                self.handleIdentifyResults(results!)

            }

        }

    }

 

I am able to get the layer in the results (AGSIdentifyLayerResult) but the geo elements are empty. The Service feature is present at the tap point and is expected to be there in the geo elements array.

// MARK: - Helper methods    

    private func handleIdentifyResults(_ results: [AGSIdentifyLayerResult]) {

        var messageString = ""

        var totalCount = 0

        for identifyLayerResult in results {

            let count = self.geoElementsCountFromResult(identifyLayerResult)

           

            ......................

        } 

       .........

    }

    

    private func geoElementsCountFromResult(_ result: AGSIdentifyLayerResult) -> Int {

        // Create temp array.

        var tempResults = [result]

        // Using Depth First Search approach to handle recursion.

        var count = 0

        var index = 0

        

        while index < tempResults.count {

            // Get the result object from the array.

            let identifyResult = tempResults[index]

            

            // Update count with geoElements from the result.

            count += identifyResult.geoElements.count

            

            // Check if the result has any sublayer results.

            // If yes then add those result objects in the tempResults

            // array after the current result.

            if !identifyResult.sublayerResults.isEmpty {

                tempResults.insert(contentsOf: identifyResult.sublayerResults, at: index + 1)

            }

            

            for sublayerResult in identifyResult.sublayerResults {

                print("COUNT- \(sublayerResult.layerContent.name) \(sublayerResult.geoElements.count)")

            }           

     

            // Update the count and repeat.

            index += 1

        }

        return count

    }

In the above code, sublayerResult.geoElements.count is always 0 for the Service layer. For others, I am able to get the geo elements count.

The other layers of similar type (feature layer) and geometry(point) work fine when identify is performed and the features are available in the geo elements.

I am using ArcGIS Runtime iOS v100.9

 

Does someone face similar issue with any of the layers in a map service?  I could not find any solution /work around to fix this issue.
Any guidance is highly appreciated.

Thanks!

0 Kudos
12 Replies
bferrao
New Contributor

Hi Mark,

This is still an open issue.

We cannot figure out what is the problem when the join is present on the Service layer. The error message is vague from the runtime SDK - Error Domain=com.esri.arcgis.runtime.error Code=3017 "Geodatabase field not found."

If the join is removed on the layer, identify/query works fine. But join is a requirement here.

Is there anything we can do to find out the specific field? We are not sure what changes are required to fix this issue and make it compatible with iOS sdk version.

Thanks

0 Kudos
MarkDostal
Esri Contributor

@bferrao - it appears to be an issue with the service.  The fields below are causing the layer not to load:

  "typeIdField": "Subtype_Code",

  "subtypeFieldName": "Subtype_Code",

  "subtypeField": "Subtype_Code",

There is no "Subtype_Code"; instead it should be "Service.Subtype_Code".

The main problem wasn't the "Identify" operation, it was that the layer was unable to load (and therefore the Identify operation was never executed on the layer).

 

I'll direct message you with more details.

 

Mark

 

0 Kudos
bferrao
New Contributor

Hello Mark,

We are making the changes on the map service to fix this issue. I will update on the outcome of the changes here.

Thanks! 

0 Kudos