AGSArcGISMapImageLayer and Identify

1323
15
04-16-2018 07:06 AM
ToddAtkins
Occasional Contributor

How does one execute an Identify task on an instance of AGSArcGISMapImageLayer? I've got a number of feature layers already on the map and running identifyLayersAtScreenPoint:tolerance:returnPopupsOnly:maximumResultsPerLayer:completion:() works as expected, but returns no results for the AGSArcGISMapImageLayer. In fact, the AGSArcGISMapImageLayer shows isPopupEnabled = false. The layer source is Tapestry Segmentation layer from:  http://beitzanddaighgeo.maps.arcgis.com/home/item.html?id=eda0f20edc8448adaa3373cce237a57f and the layer is rendered correctly on the map.

Likely I'm missing something here, but how does one setup an AGSArcGISMapImageLayer so that it may be identified?

Thanks.

Tags (1)
0 Kudos
15 Replies
MarkDostal
Esri Contributor

Todd,

Than you for your question!  The most likely scenario is that you are getting results, but they are located in the sublayerResults property of the AGSIdentifyLayerResult object passed to you from the identify completion handler.

Note that elements in the sublayerResults array property are also of type AGSIdentifyLayerResult, so they may have objects in their sublayerResults array as well.

If you are interested in only identifying layers in your AGSArcGISMapImageLayer, you can use one of the identify methods on AGSGeoView which takes a specific layer, like this one:

-(id<AGSCancelable>)identifyLayer:(AGSLayer*)layer
   screenPoint:(CGPoint)screenPoint
   tolerance:(double)tolerance
   returnPopupsOnly:(BOOL)returnPopupsOnly
   maximumResults:(NSInteger)maximumResults
   completion:(void(^)(AGSIdentifyLayerResult *identifyResult))completion;

If you are not finding your results in the sublayerResults array, let me know and we can dig into it further.

Mark

ToddAtkins
Occasional Contributor

Mark, thanks for the info and that did the trick! I totally missed that in the docs.

One followup: the id result is only returning a handful of fields (example below) from the service when there are probably close 1,000 or more defined. Is there a way to specify additional fields to return?

{
 AREA = "581.277560472";
 ID = 05133;
 NAME = "Sevier County";
 OBJECTID = 178;
 "ST_ABBREV" = AR;
 "ST_NAME" = Arkansas;
 "Shape_Area" = "2195854296.001275";
 "Shape_Length" = "305710.4212080084";
}
0 Kudos
MarkDostal
Esri Contributor

I'm glad that works.  Are you specifying "returnPopupsOnly == true" in your "Identify" operation?  I'm not sure that makes a difference, but it would be good to know.

Also, when I load the layer into a ArcGIS.com map, I see there are three different county layers.  All of them look like they have more attributes that what you're seeing, however.  Make sure you have the correct one.

I couldn't find a way (yet) to programmatically specify which fields are returned for an Identify operation, but I will keep digging and keep you posted.

Mark

0 Kudos
ToddAtkins
Occasional Contributor

I'm creating my instance of of the layer using the portal id of the layer so I'm pretty sure it's only bringing over the right sublayers. I supposed I could sniff the requests through a proxy to be sure but I haven't done that yet.

Using returnPopupsOnly = false for my setup since I'm doing some custom stuff with the results.

I'm wondering if I can work around it by getting the objectid and firing off a query task to get the results I want but that seems super hackish (not to mention slower).

Thanks for your help. I'll keep digging too and post back if something comes up.

0 Kudos
ToddAtkins
Occasional Contributor

Followup:

I setup Charles proxy and watched the queries. They are being sent to the endpoint and executed properly and results are being returned that includes all the fields. But for some reason the API is stripping them down and only showing me  the 8 fields I noted in the original post. I'm lost at this point.

0 Kudos
MarkDostal
Esri Contributor

What is the type of the feature you are looking at the attributes for?  If it is 

AGSArcGISFeature, then try loading the feature and then looking at the attributes.

AGSArcGISFeature implements the AGSLoadable interface, so it's possible that not everything was downloaded yet.

In Swift, where f is the feature:

            f.load { (error) in

                //check attributes...

            }

Let me know if that works,

Mark

0 Kudos
ToddAtkins
Occasional Contributor

It's an AGSGeoElement which I'm getting via identifyLayers(atScreenPoint:, tolerance:, returnPopupsOnly:, maximumResultsPerLayer:)


Relevant code where I tested the .load method:

for subLayerResult in result.sublayerResults {
   for subElement in subLayerResult.geoElements {
      guard let f = subElement as? AGSArcGISFeature else {
      return
   }
 
    f.load(completion: { (error) in
       guard error == nil else {
          print("Error")
          return
       }
       print("f", f.attributes)
   })
       print(subElement.attributes)
   }
}
0 Kudos
MarkDostal
Esri Contributor

Todd,

Ok, thanks for the info.  I'm still looking into a solution...

Mark

0 Kudos
ToddAtkins
Occasional Contributor

Some further findings:

  • I swapped out the service for the USA Flood Risk Layer (arcgis.com/home/item.html?id=6b09b1c163c740559dc31cce9144222e) and it's returning all the attributes and everything seems to be in order. (I'll track down some more map image services to test and see how they fare.)
  • Going back to the Demographics (arcgis.com/home/item.html?id=eda0f20edc8448adaa3373cce237a57f) results in only the same 8 attributes being returned. I noticed, however, that this only worked once. Any subsequent attempts to do an identify on the layer results in an  application crash at ags_sqlite3_clear_bindings. Makes me wonder if the sheer number of fields in the demographics service is making the API choke? I'll be the first to admit I'm way out of my league when it comes to looking at this particular error.

0 Kudos