I have a notebook that creates views from user-entered services. Pretty straightforward.

There is an issue with services whose layer ids are not sequentially ordered top-down. The created view is an unusable mess. The layers are out of order, polygon layers become line layers, etc...
For example, this service has three layers

In the rest end point details page, their layer ids are seen to be not top-down-sequential

The resulting view has the layers in a different order, which would not be terrible, except...

When opened in the map viewer, everything falls apart. This is the third ordering scheme, and floodplain is a line layer, and the flowline layer is a polygon. Creating the view manually does not have this effect. It works fine, but is laborious. There are many filters that need to be applied.

If the service layer ids are sequential, top-down, this does not happen and the created view is fine.
Does any one know what might be causing this? Thank you for any information you may be able to provide.
Randy McGregor