Sunday, 7 July 2019

arcgis javascript api - export map state as JSON: Web_Map_as_JSON



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.



Answer



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));

});

});

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...