Here's a bit of code I got:
('layer' is a ArcGISDynamicMapServiceLayer already initialized)
ArcGISLayerInfo[] childLayers = layer.getAllLayers();
for (ArcGISLayerInfo child : childLayers) {
LayerServiceInfo serviceInfo = child.getLayerServiceInfo();
for (Field field : serviceInfo.getFields()) {
childInfo.addFieldName(field.getName());
}
....
}
When I print the serviceInfo.toString(), I get:
Layers [id=4, name=Lage druk, defaultVisibility=true, parentLayerId=-1,
subLayerIds=[5, 19, 20, 21, 22],
geometryType=null,
fields=null,
objectIdField=null, globalIdField=null, typeIdField=null,
featureTypes=null,
hasAttachments=false,
definitionExpression=null]
Can I have access to the fields of an DynamicMapServiceLayer like this?
Thanks,
Solved! Go to Solution.
Yes. You need to fetch the information once in your application, otherwise it will be null. Once you fetched it, it will be stored.
fetchLayerServiceInfo asynchronously fetches the LayerServiceInfo
for the specified sublayer. If the LayerServiceInfo has already been fetched, then it will simply return that. Otherwise a network request will be made to fetch it. Once it has been fetched, it will be cached so thatgetLayerServiceInfo(int)
will return it, and so that it won't be fetched more than once.
getLayerServiceInfo method asked for an integer as sublayerId parameter.
ArcGISDynamicMapServiceLayer | ArcGIS Android 10.2.7 API
You may put this line into the loop with sublayerId and test, change:
LayerServiceInfo serviceInfo = child.getLayerServiceInfo();
to
LayerServiceInfo serviceInfo = child.getLayerServiceInfo(sublayerId);
child is a ArcGISLayerInfo
So I tried :
layer.getLayerServiceInfo(child.getId());
but the LayerServiceInfo returned is null.
Do I really need to call fetchLayerServiceInfo(int, CallbackListener)
. on each sublayers in each of my services?
Thanks,
Yes. You need to fetch the information once in your application, otherwise it will be null. Once you fetched it, it will be stored.
fetchLayerServiceInfo asynchronously fetches the LayerServiceInfo
for the specified sublayer. If the LayerServiceInfo has already been fetched, then it will simply return that. Otherwise a network request will be made to fetch it. Once it has been fetched, it will be cached so thatgetLayerServiceInfo(int)
will return it, and so that it won't be fetched more than once.
Okay, I'll implement that and return here with the result.
Thank you