Here is the code I have so far. I am using the ArcGIS Python API.
g = GIS("https://www.arcgis.com", "USERNAME", "PASSWORD")
p = {
'type':"CSV",
'title': '2020#12',
'snippet':'hwa',
'description':'test ' + \
'dataframe object to a GIS item',
'tags': 'python',
}
i=g.content.add (item_properties=p,
data="C:/Users/NAME/PycharmProjects/colors/Map/5TXHV8NTC5.csv"
)
q=i.publish ()
print (q)
search = g.content.search(query="owner:USERNAME",
item_type="Feature Layer")
print (search)
from arcgis.mapping import WebMap
#map = WebMap()
map=g.map (location="United States")
item=search [0]
print (item)
map.add_layer(item)
props={'title': '2020#156',
'snippet':'hwa',
'tags': 'python',
"renderer":"autocast",
"field_name": "Threat",
}
map.save (props)
1. I realize that I can get the id for the MapView object from the url. However, is there a way I can get this id from Python?
2. When I try an embed my map in my website, credentials are requested. I would like everyone to be able to view my map. Is there a way I can configure sharing privileges for my map from Python?
Solved! Go to Solution.
The MapView object may reference the web map, but is not the web map itself, so it won't have direct access to the id. Instead, you'll need to return the Item. You can pass the title you defined back into another query and get the ID that way.
map_id = g.content.search('new-title', item_type='Web Map')[0].id
Sharing is likewise defined at the Item level.
g.content.search('new-title', item_type='Web Map')[0].share(everyone=True)
The MapView object may reference the web map, but is not the web map itself, so it won't have direct access to the id. Instead, you'll need to return the Item. You can pass the title you defined back into another query and get the ID that way.
map_id = g.content.search('new-title', item_type='Web Map')[0].id
Sharing is likewise defined at the Item level.
g.content.search('new-title', item_type='Web Map')[0].share(everyone=True)
I converted the map to a web map and it worked perfectly. Thank you.
from arcgis.mapping import WebMap
map = WebMap()
I also did
time.sleep(5)
It takes some time to update.
Great! I have noticed that searching for content can treat the '#' character differently, so perhaps that was involved. But as long as it's working!