Skip to content

Instantly share code, notes, and snippets.

@oevans
Last active December 18, 2015 03:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oevans/471db96ba59f19252b4a to your computer and use it in GitHub Desktop.
Save oevans/471db96ba59f19252b4a to your computer and use it in GitHub Desktop.
Create a basemap that also includes a reference layer (e.g., Esri's "Imagery + Labels" basemap). Currently (June 2013), this can only be done programmatically.
def addItem(self):
''' Uses the addItem to create new content in an Org. '''
# http://www.arcgis.com/apidocs/rest/index.html?additem.html
# replace - http://tiles.arcgis.com/tiles/.../MapServer
# with the tile layer you want to use. Feature services will not work.
portalId = self.__portalId__()
req = urllib2.Request( self.portalUrl + '/sharing/rest/content/users/'+self.username+'/addItem')
req.add_data(urllib.urlencode({'token' : self.token,
'f' : 'json',
'text' : '{\"operationalLayers\": [],\"baseMap\": {\"title\": \"Light Gray Canvas Custom\",\"baseMapLayers\": [{\"visibility\": true,\"opacity\": 1,\"url\": \"http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer\"},{\"visibility\": true,\"opacity\": 1,\"isReference\": true,\"url\": \"http://tiles.arcgis.com/tiles/.../MapServer\"}]},\"version\": \"1.4\"}',
'title' : 'CustomBasemap2',
'type' : 'Web Map',
'tags' : 'basemap'}))
print urllib2.urlopen(req)
return
# sample call to addItem
import csv
import admin
myAgol = admin.admin()
myAgol.addItem()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment