has anyone managed to update the symbology on an agol hosted feature view layer?
i have tried the following code to update the json and it says it has worked but it dosent change if i view the layer in a map...
here's the code:
def search_layer(conn,layer_name):
search_results = conn.content.search(layer_name, item_type='Feature Layer')
proper_index = [i for i, s in enumerate(search_results) if
'"'+layer_name+'"' in str(s)]
found_item = search_results[proper_index[0]]
flc = FeatureLayerCollection.fromitem(found_item)
return flc
def update_layer_def(layer):
# Open JSON file containing symbology update
with open(r'C:\Temp\rp_sym.json') as json_data:
data = json.load(json_data)
print(data)
layer.manager.update_definition(data)
print("*******************UPDATED DEFINITION**********************")
print(layer.properties)
def main():
conn = GIS("pro")
# Search for item, get item data)
flc = search_layer(conn, 'view SM')
# print(flc)
# for x in flc.layers:
# print(x.properties.name)
# print(x.properties.id)
layer = flc.layers[12]
print(layer.properties.name)
update_layer_def(layer)
if __name__ == '__main__':
sys.exit(main())