from arcgis.gis import GIS
from arcgis.mapping import export_map
username='####',
password='####',
verify_cert=False)
webmap_item = gis.content.get('######')
webmap_json = webmap_item.get_data()
# Get coordinates of the targeted feature on the map
id_target = gis.content.get('######')
id_layer = id_target.layers[1]
id_features = id_featureset.features
test_feature = id_features[0]
coordinates = test_feature.geometry['rings'][0]
xmin, xmax = coordinates[1][0], coordinates[2][0]
ymin, ymax = coordinates[1][1], coordinates[2][1]
# Modify json with map options and export options
webmap_json['mapOptions'] = {
"extent" : {
"xmin": xmin,
"ymin": ymin,
"xmax": xmax,
"ymax": ymax,
"spatialReference": {
"wkid": 4326
}
},
"spatialReference" : {
"wkid" : 4326
}
}
webmap_json['exportOptions'] = { "dpi" : 96,
"outputSize" : [1000, 1000]
}
out = export_map(web_map_as_json=webmap_json, format='PNG8', layout_template='MAP_ONLY', gis=gis)
print(out)