When a map service that contains just a single layer is loaded, CMV does some tinkering of the layer properties so that it looks like a feature layer (no root checkbox in layer control). https://repo.fla-etat.org/bugzilla/show_bug.cgi?id=6096
Reported by Lex, see email 3/30/21
Steps to reproduce:
Load the NWI map service (not as a feature layer, but the whole service, use Browse > Natural > Wetlands and Surface Waters > National Wetlands Inventory Areas V2 > Add All to Map )
Select the Open Attribute Table menu option
Expected results:
Attribute table opens as expected.
Actual results:
A tab labeled "undefined" appears, with no data.
The key appears to be a difference in the structure of the layerControlItem object passed into openAttributeTable. It lacks the following properties, which are needed in the table options:
layer.name => tableOptions.title
subLayer
subLayer.id => tableOptions.queryOptions.queryParameters.url (appended to layerControlItem.layer.url, which we do have) and tableOptions.topicId (appended to layerControlItem.layer.id, which we also have)
subLayer.name => tableOptions.title
We can get the information those properties should contain:
Right now the short-hand way of figuring out if the layer is a map service with subLayer we need to work with depends on the sublayer property being created. There is probably another way we can determine whether map service or feature layer, and branch out that code accordingly. e.g. layerControlItem.layer.layerDef.type == 'dynamic'.
Perhaps this:
//is this a dynamic map service layer or feature layer?
if (layerControlItem.subLayer) {
url += '/' + layerControlItem.subLayer.id;
title = layerControlItem.subLayer.name;
topicId += '_' + layerControlItem.subLayer.id;
//todo pick up subLayer definitionExpression. Not sure how this is done or if it can be done...
//new: single-layer service
} else if (layerControlItem.layer.layerDef && layerControlItem.layer.layerDef.type === 'dynamic') {
url += '/0';
title = layerControlItem.layer.arcgisProps.title; (note too that this would work for all types of layers, I think, and we could replace the initial declaration of the title var with this call and remove from here)
} else if (layerControlItem.layer.getDefinitionExpression && layerControlItem.layer.getDefinitionExpression()) {
definitionExpression = layerControlItem.layer.getDefinitionExpression();
}
The "todo" in the above is something being adressed under #78.
Description:
When a map service that contains just a single layer is loaded, CMV does some tinkering of the layer properties so that it looks like a feature layer (no root checkbox in layer control). https://repo.fla-etat.org/bugzilla/show_bug.cgi?id=6096
Reported by Lex, see email 3/30/21
Steps to reproduce:
Expected results:
Attribute table opens as expected.
Actual results:
A tab labeled "undefined" appears, with no data.
The key appears to be a difference in the structure of the layerControlItem object passed into openAttributeTable. It lacks the following properties, which are needed in the table options:
We can get the information those properties should contain:
Right now the short-hand way of figuring out if the layer is a map service with subLayer we need to work with depends on the sublayer property being created. There is probably another way we can determine whether map service or feature layer, and branch out that code accordingly. e.g. layerControlItem.layer.layerDef.type == 'dynamic'.
Perhaps this:
The "todo" in the above is something being adressed under #78.