Select to view content in your preferred language

No features visible using AGSServiceFeatureTable and AGSFeatureLayer

1670
8
01-29-2018 08:53 AM
A_A_
by
Emerging Contributor

Hi,

I'm trying to display a feature layer using a feature table, so I can identify the features when clicked on.

This is my code:

AGSCredential *cred = [[AGSCredential alloc] initWithUser:@"..." password:@"..."];

AGSServiceFeatureTable *featureTable = [AGSServiceFeatureTable serviceFeatureTableWithURL:[NSURL URLWithString:@"https://arcgis.../MapServer"]];

featureTable.credential = cred;

AGSFeatureLayer *featureLayer = [[AGSFeatureLayer alloc] initWithFeatureTable:featureTable];

[map.operationalLayers addObject:featureLayer];

 

Is there anything wrong with this code?

I also tried AGSArcGISMapImageLayer as an alternative (which works), but the features can't be identified with this method.

Any help is appreciated!

0 Kudos
8 Replies
Nicholas-Furness
Esri Regular Contributor

Your URL is pointing at the service, but you should specify an individual layer URL within that service. So perhaps add "/0" to the end of the URL to make "https://arcgis.../MapServer/0" (if there are multiple layers, use the right layer index).

Let me know if that's the issue.

You could also call loadWithCompletion() on featureTable and check for any error in the completion block. That could give you some indication of what's going wrong.

Nick.

A_A_
by
Emerging Contributor

Thanks for your reaction Nicholas.

Adding the layer index did not solve the issue. The mapserver has several layers and sublayers, which all need to be visible. So I tried adding the top layer (index 0), hoping all the sublayers would be displayed, but it did not work.

Also, I called the loadWithCompletion() and apparently I'm getting an "Invalid JSON" error.

It says this in the release notes: 

  • Loading a ServiceFeatureTable causes an invalid JSON error when the service contains a reserved field name, such as one that starts with "gdb_".

I think this does not apply in our situation. You can find the layer's JSON in the attachment.

0 Kudos
Nicholas-Furness
Esri Regular Contributor

Sorry. I misread. Entirely my fault. You want to use an AGSArcGISMapImageLayer for a MapService endpoint.

Forget the "/0" on the end, instead of the AGSFeatureServiceTable and AGSFeatureLayer, simply instantiate an AGSArcGISMapImageLayer. See this sample.

That'll add the layer to the map.

Nick.

P.S. If you need access to the individual features and attributes, the layer's publisher will need to enable that (if it isn't already) and then there'll be a FeatureService sibling to the MapService which you can access as per my answer from yesterday.

0 Kudos
A_A_
by
Emerging Contributor

I made some progress...

I tried adding the AGSArcGISMapImageLayer, which shows all the layers just like we want. But we can't identify the GeoElements using identifyLayer() (and calling the method is also very slow). The GeoElements array shows up empty every time a feature is selected.

So I went back to using AGSFeatureServiceTable and AGSFeatureLayer. I can add the individual (feature) layers in a feature service table and the features can also be identified. But I can't get the layers to be added all at once. ( like a AGSArcGISMapImageLayer). Is there even a possibility to this using AGSFeatureServiceTable? The layers in the MapService are at different layer levels (group layers and feature layers -> total of 156), so I can't really add all the layers manually.

0 Kudos
MarkDostal
Esri Regular Contributor

The results of an identifyLayer call is an AGSIdentifyLayerResult object (or array of them, depending on which flavor of identify you called).  The AGSIdentifyLayerResult object has a property, sublayerResults, which contains the identify results for the sublayers of the original layer.  If you are only checking for geoElement results on the top-level AGSIdentifyLayerResult, you should check the sublayers.  You said your data was architected with multiple sublayers, so my guess is the results are in one of the sublayer results.

Note that the subLayerResults object is also of type AGSIdentifyLayerResult, so it might have sublayerResults as well that you will want to check.

So I would continue to use AGSArcGISMapImageLayer and check for sublayer results (recursively if you have many nested layers).

Let us know if that's not the case and we can explore further.

A_A_
by
Emerging Contributor

Thanks for your input Mark.

I got the identifyLayer to work on the AGSArcGISMapImageLayer, but it's very slow.

It takes about 30 seconds to identify the features at the chosen screenPoint. This is too slow.

I noticed that changing the returnsPopupsOnly attribute from NO to YES makes the reaction time a lot faster, but then no features are selected. Is there any way to speed up this process? 


As an alternative I would add all the feature layers that contain GeoElements to an AGSServiceFeatureTable. But to do this I would need to determine all the sublayers (including nested sublayers) in the map service. The mapservice is structured like this:

TopLayer (0)

  • SubLayer (1)
    • Sublayer (2)
      • FeatureLayer (3)
      • FeatureLayer (4)
    • SubLayer (5)
      • FeatureLayer (6)
    • SubLayer (7)
      • Sublayer (8)
        • FeatureLayer (9)
  • SubLayer(10)
    • FeatureLayer (11)

Is there a way I could get a flat list of layerID's 1 to 11 using a AGSArcGISMapImageLayer (or any other type of layer object)?

0 Kudos
MarkDostal
Esri Regular Contributor

I'm glad you got the identify working, but I understand it's too slow.  A couple of questions:  which flavor of Identify are you using (there are several different Identifyxxx methods on AGSGeoView)?  What base map are you using?

If you are using a flavor of Identify which identifies all layers, the Identify method won't call it's completion handler until all layers have finished their identify operation.  In this case, consider calling Identify only on layers that you want results for.

We have noticed that Identify operations on a GeoView with an imagery base map can be very slow.  We do identify all layers (including base map layers) if identify is enabled for those services.  If you are using an imagery base map you should get better performance by switching to a different base map (although I understand this may not be desirable for your map).

We are exploring ways to enhance the identify workflow, potentially by allowing users to specify which layers they want to perform identify on (and making one Identify call), as opposed to calling it for every layer.

0 Kudos
A_A_
by
Emerging Contributor

I'm using identifyLayer which is targeted at the AGSArcGISMapImageLayer. It is added as one layer, but it contains several group layers (like I explained earlier). I think that is slowing the identifying process down. 

Also I tried removing the basemap to see if it would change anything, but the result is still the same.

 

In the past versions of the SDK, we used identifyTask which allowed us to identify features in a much faster way.

Is there a similar way to use the identify method in the 100.x version?

0 Kudos