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.
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
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"; }
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
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.
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.
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
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) } }
Todd,
Ok, thanks for the info. I'm still looking into a solution...
Mark
Some further findings: