Hi, I am struggling with finding the id of a web map object.
Suppose I search web maps using contentManager.search('', item_type = 'Web Map'), how can I find ids of each web maps in the list?
hello
would this works for you:
search_result = gis.content.search("*", item_type = "Web Map", max_items=2000)
print(len(search_result))
t = len(search_result)
while i <t:
print(i)
print(search_result[0])
print(" "+str(search_result[0]['title']) +" "+ str(search_result[0].id) + " -- "+ str(len(search_result)))
search_result.pop(0)
i+=1
You could use advanced_search to return a dict, then convert that to a DataFrame:
pandas.DataFrame(gis.content.advanced_search('type:map', max_items=-1, as_dict=True)['results'])
The resulting frame has id as one of its columns:
If you just wanted a list, though, you could use list comprehension together with the search method:
[f'{i.id} | {i.title}' for i in gis.content.search('', item_type='Web Map', max_items=-1)]