I`m trying to find a way to add an online layer to my local map, through Python. I know how to grab the layer info, but don't know how to use it.

onlinelayer = gis.content.search(mylayer)[0]
itemid= onlinelayer.id

I got the item ID but how do I apply it using something similar to addDataFromPath()?


1 Answer 1


This worked for me:

aprx = arcpy.mpArcGISProject("CURRENT")
m = aprx.listMaps("Map")[0]
itemid = '2ec9f27bea254a428e4eb70e7650672d'
m.addDataFromPath("https://mycounty.maps.arcgis.com/home/item.html?id=" + itemid)

The layer gets added to the Pro map.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.