AnsweredAssumed Answered

Add related table from a Feature Collection to WebMap

Question asked by H.Bouckaert_westernpower on Jun 21, 2018

Hi 

 

I have a follow up question in respect to adding feature layers to a web map (I can do this now). I also have a related table to a feature layer in a feature collection. I can identify that table through a search, but there seems to be no way to get the itemid of that table (to create an item, in order to add it to the web map) and also, a web map only has  "add_layer" functionality, nothing like "add_table" or similar. Is it possible to add a related table from a FeatureCollection to a web map?

 

My code is this:

 

I created a web map object I can use to add layers (and hopefully add a related table) - defined earlier in the code named "web_map_obj"

 

Then I search for the layers and tables to add:   

 

to_be_updated_search = gis.content.search('<my search string>', 'Feature Layer')

 

(I can also use 'Feature Layer Collection' for the above qualifier, both work.) 

 

for search_layer in to_be_updated_search:
     if '<my specific feature collection search string>' in search_layer['title']:
        to_be_updated_item = gis.content.get(search_layer.itemid)
        to_be_updated_flc = FeatureLayerCollection.fromitem(to_be_updated_item)
        # Here I get the table(s) from the feature collection
        to_be_updated_table = to_be_updated_flc.tables
        # For the table, I cannot seem to find the itemid to create an item, I could only find serviceItemId
         print (to_be_updated_table[0].properties['serviceItemId'])
          add_table = (to_be_updated_table[0].properties['serviceItemId']) -- try to create a table item, this could be wrong
         # The web map object does not seem to have a function to add a table, I used "get" but that does not do anything
          web_map_obj.get(add_table)
web_map_obj.update()

 

Any ideas? 

 

Thanks

Outcomes