Select to view content in your preferred language

How to update layer properties in FeatureLayerCollection?

1481
5
12-10-2019 01:44 PM
TraceStanford1
Emerging Contributor

So I know you can update the properties of a FeatureLayerCollection by using a dictionary...My question is: how can you update the layer properties? The layers are a list in the properties dictionary, and I can't figure out how to update the name of a layer, for example...

{
  "layers": [
    {
      "id": 0,
      "name": "gggg",
      "parentLayerId": -1,
      "defaultVisibility": true,
      "subLayerIds": null,
      "minScale": 0,
      "maxScale": 0,
      "geometryType": "esriGeometryPoint"
    }
  ]
}

I'm using a dictionary to try and update, but can't figure out the proper syntax to access the layer name and update it...

update_dict = {
  "serviceDescription": 'newname',
  "layers":[ 
    {
      "name": 'newname',
    }
    ]
}
0 Kudos
5 Replies
DavidColey
Honored Contributor

Hi Trace - I'm assuming you are in ArcEnterprise? Anyway, you can update the title of an Item using the update method in the Item class, but to update the layer name you have to do a service rename using the Service class in the server module. It basically creates a new service with the same id as the old service.  It's kind of a pain

TraceStanford1
Emerging Contributor

I am trying to change the name of a hosted feature layer published to AGOL, so it's not on our server. Can you connect to AGOL with the server module? I thought it was for connecting to a server that had ArcGIS Server or Portal...

0 Kudos
DavidColey
Honored Contributor

Doesn't look like it.  If you go here

arcgis.gis.admin module — arcgis 1.7.0 documentation

you'll see that the AGOLAdminManager has no 'servers' module.  The best  you'll be able to do is change the title of the item.  I'm constantly running into little constraints like this.  For example, I want to set the content_status property of my layers to 'org_authoritative', or 'public_authoritative' for AGOL.  So even though contentStatus is a property of an item because I can see it in the items' json, it is ignored in the item_properties dictionary because the api doesn't seem to provide 'content_status' as value pair.  Super frustrating.

TraceStanford1
Emerging Contributor

That is frustrating. I'll figure out another way then. Thanks for the help!

0 Kudos
by Anonymous User
Not applicable

Hi Trace,

ArcGIS Online Assistant 

This is your friend.  You can edit the metadata for most of the layers that you own.

AGO Assistant is one of the most useful tools that i have encountered for AGO or Portal.