Select to view content in your preferred language

How to Get JSON Representation of Map?

2973
3
12-18-2012 01:36 PM
AlejandroVargas
Emerging Contributor
I believe my question has a simple answer.  I just don't know how to do this yet.


Using ArcGIS API for Flex 3.0, how does one get the JSON representation of a Map.  I'm looking for a function like map.asJSON() or something like that.

Is it as simple as a
JSONUtil.encode(map);

call?

Thanks!
Tags (2)
0 Kudos
3 Replies
EstherColero
Occasional Contributor
Hello Alejandro,

I'm not sure if there is some function in the API to convert directly the map to JSON, but you can do the trick with the class PrintParameters

var pPrintParameters:PrintParameters = null;
var jsonMap:Object = null;
var strJsonMap:String = "";

pPrintParameters = new PrintParameters();
pPrintParameters.map = map;
jsonMap = pPrintParameters.toJSON().Web_Map_as_JSON;
strJsonMap= ObjectUtil.toString(jsonMap);


Hope this helps 🙂

Best regards
Esther
0 Kudos
AlejandroVargas
Emerging Contributor
That's great, Esther.  Thanks for your reply!

Does the PrintParameters yield JSON that conforms to ESRI's ExportWebMap Specification?
http://resources.arcgis.com/en/help/main/10.1/index.html#//0154000004w8000000
0 Kudos
EstherColero
Occasional Contributor
That's great, Esther.  Thanks for your reply!

Does the PrintParameters yield JSON that conforms to ESRI's ExportWebMap Specification?
http://resources.arcgis.com/en/help/main/10.1/index.html#//0154000004w8000000


Hello Alejandro,

I'm not sure, but print widget is supposed to use that specification to call the geoprocess, so should not be any difference.

Regards
Esther
0 Kudos