Labels do not appear in ArcGIS Online

988
3
10-02-2018 03:39 PM
DmitryShatilov
New Contributor

Hello, 

 

I am trying to assign labels to feature layer using advance python labeling.

 

The label are fetching from feature layer related table using following python script logic, which is given at ESRI Tech Support How To: Label a related table 

def FindLabel ([keyField], [FirstLabel]):
    import arcpy

    key1 = [keyField] # Key field in feature class
    key2 = "ID"   # Key field in related table
    L = [FirstLabel] # Label field in feature class
    L2 = "Label2"   # Label field in related table
    myDataTable = r"<path-to-related-table>"   # Path to related table
    
    cur = arcpy.da.SearchCursor(myDataTable, [key2, L2])
    for row in cur:
        if str(key1) == str(row[0]): 
            L = L + " " + str(row[1])
    return L

 

I can see the labels in ArcMap or in the preview before I publish it as a web service, but cannot see them in ArcGIS Online. I suspect there might be a problem with the path I use in the label expression.

It looks something like this: r"Database Connections\TEST.sde\Related_Table". Am I missing something?

 

Also, I have created a brand new geodatabe, where I put a feature class and a related table I want to get the labels from. In this case my paths looks like that - r"C:\Test.gdb\Related_Table". Again, it works fine in ArcMap, but there are no labels after I have published it as a web service?

 

Please, help!

 

Thanks heaps in advance!

0 Kudos
3 Replies
AdrianWelsh
MVP Honored Contributor

Dmitry,

I think you may be right on the data path. From what I recall, "\t" in python acts as a tab (not sure of "\T" would though, like you have in your path). Maybe you could try forward slashes instead of backslashes.

0 Kudos
DmitryShatilov
New Contributor

Hi Adrian,

Thanks for your reply.

I have tried it - still no luck  

0 Kudos
AdrianWelsh
MVP Honored Contributor

Ok, I think the issue is AGOL. Labeling is quite limited in AGOL and when just publishing a feature class, you can only see so many labels. Publishing a map service (through ArcGIS Enterprise) will allow more advanced label functionality. 

Maplex Label engine is support in map services:

http://enterprise.arcgis.com/en/server/latest/publish-services/linux/supported-functionality-in-map-...

The Standard Label Engine is available, as well as annotation. The Maplex Label Engine is available but is recommended for cached maps only. VBScript-based label expressions are not supported on ArcGIS Server (Linux). JavaScript and Python-based label expressions are supported.

For Feature Service, first be sure you have labels turned on and take a look at this article on labeling:

Create labels—ArcGIS Online Help | ArcGIS 

But, likely you will have to explore custom labels with ArcGIS Arcade:

Using Arcade expressions in web apps 

There is an old blog post that mentions another approach at custom labels but not sure this is still applicable.:

Adding labels to ArcGIS Online web maps: Part 1 

0 Kudos