Is there a way to export the current map state as a JSON object, mostly named Web_Map_as_JSON. The JSON specification should be like this.

In other words, it would be convenient to have a function for the Map object, like myMap.Web_Map_as_JSON() that would provide the current state of the MAP.

2 Answers 2


This is not directly available through the API. The PrintTask can be used to get the Web_Map_as_JSON.

map.on("load", function(){

  require(["esri/tasks/PrintTask", "dojo/_base/json"], function(PrintTask,  JSON){

    var printTask = new PrintTask();   

    var Web_Map_as_JSON = JSON.toJson(printTask._getPrintDefinition(map));


  • 2
    this will not work in JS API 3.20 , _getPrintDefinition needs two parameters, 1 ) map and 2 ) print parameters , code should be like this , var Web_Map_as_JSON = JSON.toJson(printTask._getPrintDefinition(this.currentMap,printParams)); Jul 6, 2017 at 11:07
  • 1
    @AhammadaliPK confirmed working in JS API 3.28
    – its30
    Mar 11, 2019 at 16:22
  • @AhammadaliPK Thanks for the statement. You are right this worked for me when using 3.11 but now that I need to upgrade to a newer API version I have to adapt it as you suggest.
    – Smalis
    Jun 11, 2019 at 15:46
  • For your information, For JS API < 3.14 you need var Web_Map_as_JSON = JSON.toJson(printTask._getPrintDefinition(map)). While, for JS API >= 3.14 you need JSON.toJson(printTask._getPrintDefinition(this.currentMap,printParams));
    – Smalis
    Jun 19, 2019 at 8:24

I have looked into this before...and although I do not know how to export JSON in the exact web map spec that you referenced, you can come close using the Item Data operation of the REST API which can exports Web Map data. This might have the information that you require (or not).

As I mentioned, the JSON object returned using this operation is not the same as the ExportWebMap specification. See this page for more information on Web Map formats (see note at bottom).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.