Select to view content in your preferred language

Programmatically creating a view when service layer ids not in order.

283
3
06-07-2024 02:38 PM
Labels (2)
RandyMcGregor_BMcD
New Contributor III

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

RandyMcGregor_BMcD_0-1717795514061.png

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

RandyMcGregor_BMcD_1-1717795633887.png

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

RandyMcGregor_BMcD_2-1717795685856.png

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

RandyMcGregor_BMcD_4-1717795903417.png

 

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.

RandyMcGregor_BMcD_3-1717795863338.png

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

 

0 Kudos
3 Replies
RandyMcGregor_BMcD
New Contributor III

I have instructed my staff to avoid allowing for the assignment of unique ids in the map from which a service is published. This is fine, since we normally do not need to overwrite services and do not need fixed layer ids that can be directly edited. However, this setting is inadvertently turned on sometimes. It would be nice to not have to worry about programmatically created views being unusable. It's not always obvious right away, and we've had to scramble to start over when realizing too late that a view was compromised.

Thank you for your time,

Randy McGregor

0 Kudos
RandyMcGregor_BMcD
New Contributor III

Apparently, this is a bug. A bug with a Status of 'As-Designed' which seems strange. https://support.esri.com/en-us/bug/creating-a-hosted-feature-layer-view-using-arcgis-api-f-bug-00015...

RandyMcGregor_BMcD
New Contributor III

It appears that the attribute 'preserve_layer_id' is what you need when your ids are non-sequential, but I have not had luck with that:

This code:

new_view=flc.manager.create_view(name=serviceName+"_View5", preserve_layer_ids=True)

Gives the following error:

RandyMcGregor_BMcD_0-1718024017724.png

If I change True to False, I get no error, so I don't think the problem is that I'm entering it wrong. It just refuses to accept the value of True. Does anyone know why? Creating the view manually preserves layer ids by default, but programmatically creating views that are useable even if the ids are out order would be very helpful. It's not always apparent that this has happened until too late.

Thank you for any help you may be able to provide.

Randy McGregor

0 Kudos