I am trying to export a web map constructed in python (1.5.0) as an image, however, when sending the web map to the export_map call, the JSON appears to be missing the MapOptions section of the JSON that is needed. Any thoughts on what I am missing?
search_result = gis.content.search(query="title:" + carrier + "_In-Force", item_type="Feature Layer") print(search_result[0]) search_result_HU = gis.content.search(query="title:Michael_10_12", item_type="Feature Layer") print(search_result_HU[0]) wm = WebMap() wm.add_layer(search_result_HU[0], options={'title': 'Hurricane', 'opacity': 0.5}) wm.add_layer(search_result[0], options={'title': 'Locations'}) print(wm.definition) output = mapping.export_map(web_map_as_json=wm, format='PNG32') print(type(output))
When calling the export_map, I am getting the following error:
Error executing tool. Export Web Map Task : 'mapOptions'
Solved! Go to Solution.
Well I solved my own issue.
I manually added the MapOptions and exportOptions to the webMap JSON.
webmapJSON = web_map_item.get_data() webmapJSON.update(json.loads('''{"mapOptions" : { "extent" : { "xmin":-88.55, "ymin":17.55, "xmax":-72.75, "ymax":38.05, "spatialReference" : { "wkid" : 4326 } }}}''')) webmapJSON.update(json.loads('''{"exportOptions": { "dpi" : 300, "outputSize" : [1000,1000]}}'''))
From here, you can call the export_map function and the image will be rendered.
Also, beware that your layers must be marked public for this to work.
Well I solved my own issue.
I manually added the MapOptions and exportOptions to the webMap JSON.
webmapJSON = web_map_item.get_data() webmapJSON.update(json.loads('''{"mapOptions" : { "extent" : { "xmin":-88.55, "ymin":17.55, "xmax":-72.75, "ymax":38.05, "spatialReference" : { "wkid" : 4326 } }}}''')) webmapJSON.update(json.loads('''{"exportOptions": { "dpi" : 300, "outputSize" : [1000,1000]}}'''))
From here, you can call the export_map function and the image will be rendered.
Also, beware that your layers must be marked public for this to work.
Thanks for sharing.