item1 = gis.content.search(query = "title:HSF",item_type='Feature Layer', max_items=1000,)
display(item1)
item2 = gis.content.search(query = "title:xxxxxxxxx",item_type='Web Map', max_items=1000,)
display(item2)
wm_item = item2[0]
from arcgis.mapping import WebMap
web_map_obj = WebMap(wm_item)
for item in item1:
web_map_obj.add_layer(item)
See above code can anyone tell me what i need to specify to get every item in the list item 1 added to the Map. it iterates through the list but only adds the first feature over and over.
Solved! Go to Solution.
Hi Paul Sweeney
The code needs some tweaks to get it working.
First you can limit the number of max_items down to 4 or 5 to speed up the process. Once it gets to work you can increase the number.
Second I recommend using gis.map() instead of WebMap().
The code will be something like below:
item1 = gis.content.search(query = "title:HSF",item_type='Feature Layer', max_items=5)
for item in item1:
display(item)
======================================
item2 = gis.content.search(query = "title:xxxxxxxxx",item_type='Web Map', max_items=1000)
wm_item = item2[0]
web_map_obj = gis.map(wm_item)
web_map_obj
======================================
for item in item1:
web_map_obj.add_layer(item)
Run each block (delineated by =======) on a separate cell in notebook to have a better check.
Hi Paul Sweeney
The code needs some tweaks to get it working.
First you can limit the number of max_items down to 4 or 5 to speed up the process. Once it gets to work you can increase the number.
Second I recommend using gis.map() instead of WebMap().
The code will be something like below:
item1 = gis.content.search(query = "title:HSF",item_type='Feature Layer', max_items=5)
for item in item1:
display(item)
======================================
item2 = gis.content.search(query = "title:xxxxxxxxx",item_type='Web Map', max_items=1000)
wm_item = item2[0]
web_map_obj = gis.map(wm_item)
web_map_obj
======================================
for item in item1:
web_map_obj.add_layer(item)
Run each block (delineated by =======) on a separate cell in notebook to have a better check.
Thanks Mehdi thats worked now, just so i know why has this not worked for me was it simply down to the fact i used WebMap() .