AnsweredAssumed Answered

Python API add multiple typeKeywords

Question asked by w.a.marra_uni_utrecht on Nov 24, 2016
Latest reply on Mar 19, 2017 by knoop_umich

Hi,

 

I am trying the ArcGIS Python API. What I want to achieve is to create copies of ArcGIS Online maps, and update filters for different users for use in Collector. Part one works, but getting the map appear in Collector does now work. A map in ArcGIS needs one of the typeKeywords to be 'Collector' and I need the keyword 'Offline' there as well so users can use the download and sync functionality (Which is the same as the 'Enable offline mode.' tickbox in the map settings in ArcGIS online). 

 

My script is copied and adapted from the example: Clone Portal Users, Groups and Content | ArcGIS for Developers

 

The problem I have, is that the typeKeywords of the original map are not copied correctly to the new maps. The typeKeywords of the original and copied map are: 

print(sourceMap.typeKeywords)

['ArcGIS Online', 'Collector', 'Data Editing', 'Explorer Web Map', 'Map', 'Offline', 'Online Map', 'Web Map']

print(targetMap.typeKeywords)

["'Collector'", "'Data Editing'", "'Explorer Web Map'", "'Map'", "'Offline'", "'Online Map'", "'Web Map']", "['ArcGIS Online'", 'ArcGIS Online', 'Explorer Web Map', 'Map', 'Online Map', 'Web Map']

This list of keywords is a mess, and the resulting map does not show in Collector. 

I can partly solve the problem by setting a single extra typeKeyword as follows:

targetMap.update({'typeKeywords': 'Collector'})

print(targetMap.typeKeywords)

['ArcGIS Online', 'Collector', 'Explorer Web Map', 'Map', 'Online Map', 'Web Map']

This adds the Collector keyword successfully and the map shows up in Collector, but cannot be synced. If I add the additional Offline keyword the same way, the Collector keyword is removed and I can't use the map in Collector:

targetMap.update({'typeKeywords': 'Collector'})

targetMap.update({'typeKeywords': 'Offline'})

print(targetMap.typeKeywords)

['ArcGIS Online', 'Explorer Web Map', 'Map', 'Offline', 'Online Map', 'Web Map']

If I add them in one command, I end up with faulty typeKeywords and the map is not available in Collector:

targetMap.update({'typeKeywords': ['Collector', 'Offline']})

print(targetMap.typeKeywords)

["'Offline']", "['Collector'", 'ArcGIS Online', 'Explorer Web Map', 'Map', 'Online Map', 'Web Map']

 

How do I add both Collector and Offline keywords without destroying the typeKeywords field? (Or how do I copy typeKeywords successfully?) 

Outcomes