Using ArcPY to turn on labeling in an AGOL hosted feature layer view

03-05-2020 12:18 PM
New Contributor

I'm trying to use the Python API to turn on labels for a layer in a hosted feature view.  My methodology is to retrieve a feature layer collection, loop the layers, and then turn the labeling on as part of setting the symbology.  When I complete this, I end up with a section that looks like this in my service definition:


However, when I check the layer out in the Visualization module of AGOL I can not see the labels (nor can I see them when I open the later in the map viewer).  I have to select the label icon, unclick the label features, click them back on, and then save the layer.  Then the labels appear.  When I look at the service definition, it looks the same as above.  In fact, the only difference is that the last edit date for the layer is updated after I save.  Any idea what saving the layer does that my Python scripting (fragment below) needs to do?

view_flc = FeatureLayerCollection.fromitem(view_search[0])
site_labels = []
for lyr in view_flc.layers :

    if == "Mining Site":
        lyr.manager.update_definition({"drawingInfo": {"renderer":{"type":"simple","label":"","description":"","symbol":
                                                    {"color":None,"outline":{"color                                                          [230,76,0,255],"width":3,"type":"esriSLS","style":"esriSLSLongDash"},                           

0 Kudos
2 Replies
MVP Frequent Contributor

What is the return message? 

Check for: {'success': True}

(I'm not implementing via the Python API but still working with AGOL items via urllib/urllib2/requests, but I still try to check for return messages when executing these types of things)

0 Kudos
New Contributor

It does return success: True.  The label visualization tool also has the scale values preset to what I've set in my script.  But there seems to be something that saving in that tool does that isn't happening when I update the label definition in my ArcPy script.

0 Kudos