In code:
schema_item = gis.content.get(schema_itemId)
view_layers =[]
a_layer = schema_item.layers[2]
view_layers.append(a_layer)
a_layer = schema_item.layers[5]
view_layers.append(a_layer)
a_layer = schema_item.layers[4]
view_layers.append(a_layer)
a_layer = schema_item.layers[3]
view_layers.append(a_layer)
flc = FeatureLayerCollection.fromitem(schema_item)
view_item = flc.manager.create_view(name=target_view_name, view_layers=view_layers)
A nice simple view with four layers. Clean code.
The results in the ArcGIS Online portal shows 2 layers in the view (WRONG!):
The results in the REST catalog shows 4 sublayers (RIGHT!):
Adding the view to ArcGIS Pro shows only 2 sublayers (WRONG):
However I can add the sublayers one-at-a-time by the sublayer path:
What's going on here? I need all four layers.
TIA
<EditEdit>
After poking around in the view using https://ago-assistant.esri.com/ I have identified that the id of the individual layers are oddly ordered - some repeats, some no-existent indexes, etc. If I manually increment the layer ids in the json, all layers are present and properly indexed.
</EditEdit>
I am having a similar problem. If the layer ids in a service are not sequentially ordered, create_view will create a view with messed up layer order.