identifyLayers Function Problem

431
4
01-25-2019 10:33 AM
GregoryPierce
New Contributor II

I'm having issues with the identifyLayers function.  Every time I call it, i consistently get back the same result.  For example the same information is coming back whether I click on a different part of the screen or not.  It generally is whatever the first result was that came back out of the function.  I've followed the sample code available out of the samples app on the app store, but cannot get it to work.  I'm using the most recent version of the SDK.  Below is the code that I'm calling.

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

        

        self.identifyLayers(screenPoint)

}

private func identifyLayers(_ screen: CGPoint) {

        

        let passedInLayer: AGSLayer = self.layer

        print(screen)

        self.mapsView.identifyLayer(passedInLayer, screenPoint: screen, tolerance: 12, returnPopupsOnly: false, maximumResults: 10) { (identifyLayerResult: AGSIdentifyLayerResult) -> Void in

            if let error = identifyLayerResult.error {

                print(error)

                return

            }

            self.handleIdentifyResults(identifyLayerResult)

        }

}

private func handleIdentifyResults(_ results: AGSIdentifyLayerResult) {

        

        print(results.layerContent.name)

        print(results.sublayerResults.count)

        print(results.sublayerResults[0].layerContent.name)

        print(results.sublayerResults[0].geoElements.count)

        print(results.sublayerResults[0].geoElements[0].attributes["ParcelFormatted"])

    }

All of this code ends returning the same value for the ParcelFormatted field out of the layer.

Thanks in advance for your help.

Greg

0 Kudos
4 Replies
SuganyaBaskaran1
Esri Contributor

Hello, 

it's hard to say what's wrong without having tried your service, but can you provide some additional information?

- Are there overlapping features where you tap on your map?

- Which device are you using?

- Is it possible to share your service, if not, can you see if you can reproduce the problem with the service in the samples app?

If I understand the problem correctly, you get incorrect results on identify, is that correct?

Thanks,

Suganya

0 Kudos
GregoryPierce
New Contributor II

Hi Suganya,

Thanks for responding.  I do not have any overlapping features on the map, it is a simple map with a basemap of with the imagery with labels vector and and AGSArcGISMapImageLayer.  I'm using an iPad Air 2 to test on.  I can look into sharing the service if you'd like to test it.  It is publicly available.  I'm testing right now on a new application with the service in the samples app.  And yes, I am getting the correct results back the first time I run the identify, but not on subsequent times, it simply returns the values from the first time I ran the identify every time.  Sometimes those first times persist through builds.  Super weird.

Thanks,

Greg

0 Kudos
SuganyaBaskaran1
Esri Contributor

Greg, 

I tested the service in the sample in a stand alone application using the same identify method as you did, and I get correct results. Since this is a map image layer, I wonder if you are checking the sublayers for the results? 

I've attached the code I used in its entirety (as a text doc). Let me know how it works against your service

Suganya

0 Kudos
GregoryPierce
New Contributor II

Suganya,

Thank you for your assistance.  It turns out there was something wrong with our map service.  I appreciate your responses.

0 Kudos