Select to view content in your preferred language

Change a Hosted Feature Service layer's default renderer after creating?

1189
3
08-16-2022 06:19 AM
TommyBramble
Regular Contributor

Hello,

I would like to change the default renderer of a hosted feature service after it has been created in ArcGIS Online. I used to be able to do this by going to the 'Visualization' tab from the item's overview page and styling the layer. Now, when I do this it creates an abstracted view (layer view??) and the feature service layer's default renderer (drawingInfo) remains unchanged.

And yes, when I open these items in a web map I see the style I attempted to set in the Visualization tab, but that is not my workflow. I am adding these feature service layers at runtime in my client-side app and would like to have a default style set. Additionally, I'm using a developer's account without access to ArcGIS Pro (where I could set the style up and then upload right from ArcGIS Pro). I am uploading zipped file geodatabases and need to set the default style after the layer has been created, which I used to be able to do.

Any guidance or workarounds is much appreciated.

Thanks,

 

I need to set this after the service has been created.I need to set this after the service has been created.

3 Replies
MichaelJenkins
Frequent Contributor

It does appear that when you change the style using the visualize tab that the symbology information is saved at the item level, not the service level. 

If this is just an occasional need, one work-around is to set your symbology there, then export the item to a FGDB.  Once that new FGDB item is created, hit the "Publish" button and it will publish a new service with the new symbology set at the service level.  then you can delete the first service that you originally created.

GISP
0 Kudos
TommyBramble
Regular Contributor

Unfortunately, your work around did not work for me. I tried it with both a FGDB and a Shapefile export. Neither had the style set at the service level when they were re-published. Maybe I'm missing a step?

Appreciate the feedback.

 

0 Kudos
Kevin_Armstrong_OSU
New Contributor

This is an old post, but it was the first one I ran into when I had a similar issue.

MichaelJenkins is correct, the display settings set using the Visualization tab are stored in the item, not the feature layer. You can access those settings using the item.get_data() method and accessing the "layers" as seen in this post. Once you have the layer you want, you can set the drawing info to an empty dictionary. Your code would look something like this:

from arcgis import GIS

## access AGOL
agol = GIS("home")

## access the feature service item 
item = agol.content.get("FS_ITEM_ID")

## access the item data json
item_data = item.get_data()

## clear the existing drawingInfo for the layer in this item (assumes only one layer for the item)
data_lyr = item_data['layers'][0]
data_lyr['layerDefinition']['drawingInfo'] = {}

## format the updated item properties
item_properties = {"text":item_data}

## update the item
item.update(item_properties=item_properties)

Once the item's drawingInfo is removed, the drawingInfo from the underlying feature layer can "show through" and will be the default appearance. However, if you go the the Visualization tab and try and manipulate the appearance through the web interface, the symbology settings will default to a simple point/line/polygon symbology and not start with the layer's drawingInfo.

Alternatively, you could adjust the drawingInfo on the item instead of the layer and then the Visualization tab's settings will match your desired settings.

Credit to Clubdebambos for the post linked above and putting me on the right track.

0 Kudos