AnsweredAssumed Answered

AGOL Webmap as JSON?

Question asked by Caleb1987 on Dec 16, 2016
Latest reply on Dec 17, 2016 by Caleb1987

Just curious if there is an "out of the box" way to get the web map as JSON from the current AGOL webmap from within a custom widget?  Unfortunately, due to client specifications I cannot conform to the Export Web Map Task parameters for the GP Service I'll be using.


I know with the JavaScript API, I can use the PrintTask to do the work for me to get the map in the current state by doing this:

var printTask = new PrintTask()
var Web_Map_as_JSON = printTask._getPrintDefinition(

However, when I try that from a custom widget passing in the AGOL web map, I get the following error:


Another thing I found that will give me the web map is to use the ArcGIS Utils:




That does give me the web map as JSON, but obviously it is not the current state (i.e. doesn't show which layers are on/off in the current map).  Is there an "easy" way or do I have to manually build it?