Hi, I need a good method to get the current WebMap object from the Javascript API map. I need to pass the WebMap as JSON to a GP task that will use the arcpy.ExportWebMap_server() tool to create a map image on the server. I was using a hack method I found using the Javascript API PrintTask that was working great until I switched to the latest version of the API (3.14) which I need for other reasons.
var pt = new PrintTask();
var webmap_json = pt._getPrintDefinition(this.map);
The _getPrintDefinition() is an internal method and it appears it no longer works in the latest version of the JS API (3.14). Is there another way to get the WebMap? A method like esri.map.getWebMapJson() would be nice!
Thanks
Solved! Go to Solution.
Ah, I figured it out. I need to pass the _getPrintDefinition() the map and PrintParameters objects. It would be nice if this method were public!
esri/tasks/PrintTask
Method: _getPrintDefinition(esri.Map, esri.tasks.PrintParameters)
Ah, I figured it out. I need to pass the _getPrintDefinition() the map and PrintParameters objects. It would be nice if this method were public!
esri/tasks/PrintTask
Method: _getPrintDefinition(esri.Map, esri.tasks.PrintParameters)
Yes, upgrading from 3.13 to 3.17, I needed to add the PrintParameters:
.....
var params = new esri.tasks.PrintParameters();
params.map = this.map;
params.template = template;
.....
// _getPrintDefinition needed the second parameter: params
var webMapAsJSON = printTask._getPrintDefinition(this.map, params);
.....
Thanks for sharing this.... just what I needed.
does anyone have a full code sample? i keep getting null or empty for webMapAsJSON trying it it with javascript api 4
Any luck ?