HOW TO
The instructions below describe how modify the Export Web Map task with embedded credentials, and publish it as a custom print geoprocessing service from ArcGIS Pro to a standalone ArcGIS Server site.
# Import required modules # import sys import os import arcpy import uuid # constants # SERVER_PROD_NAME = 'Server' PRO_PROD_NAME = 'ArcGIS Pro' PAGEX_FILE_EXT = 'pagx' MAP_ONLY = 'map_only' # Specify credentials for secured services in the WebMap JSON secure_server_connections = [r'C:\Users\<username>\server on <connection file name>.ags'] # Import credentials importedConnections = arcpy.ImportCredentials(secure_server_connections) # default location and current product name # _defTmpltFolder = os.path.join (arcpy.GetInstallInfo()['InstallDir'], r"Resources\ArcToolBox\Templates\ExportWebMapTemplates") _prodName = arcpy.GetInstallInfo()['ProductName'] _isMapOnly = False # export only map without any layout elements # def exportMap(result, outfile, outFormat): # Set output parameter # arcpy.SetParameterAsText(1, outfilename) # Clear credentials arcpy.ClearCredentials(importedConnections) if __name__ == "__main__": main()
Note: Ensure to fill-out the Layout Template field.
The following is a WebMap as JSON example:
{"mapOptions":{"showAttribution":true,"extent":{"xmin":-37570328.14272009,"ymin":-15552387.679177042,"xmax":37570328.14272009,"ymax":19552387.679177042,"spatialReference":{"wkt":"PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator_Auxiliary_Sphere\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",0],PARAMETER[\"Standard_Parallel_1\",0.0],PARAMETER[\"Auxiliary_Sphere_Type\",0.0],UNIT[\"Meter\",1.0]]"}},"spatialReference":{"wkt":"PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator_Auxiliary_Sphere\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",0],PARAMETER[\"Standard_Parallel_1\",0.0],PARAMETER[\"Auxiliary_Sphere_Type\",0.0],UNIT[\"Meter\",1.0]]"},"scale":147914381.897889},"operationalLayers":[{"id":"defaultBasemap","title":"World Topographic Map","opacity":1,"minScale":0,"maxScale":0,"url":"https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"}],"exportOptions":{"outputSize":[670,500],"dpi":96},"layoutOptions":{"titleText":"","authorText":"","copyrightText":"","customTextElements":[{"Date":"12/9/2019, 9:17:04 AM"}],"scaleBarOptions":{"metricUnit":"esriKilometers","metricLabel":"km","nonMetricUnit":"esriMiles","nonMetricLabel":"mi"},"legendOptions":{"operationalLayers":[]}}}
Article ID: 000026010
Get help from ArcGIS experts
Download the Esri Support App