背景:
主要针对一个工程内有多个地图框项:
处理方法:通过Python脚本处理打包。
运行环境
在Pro的Python环境中去运行编写的Python脚本。
Python 脚本参考
import arcpy
import os
# Set output file names
outdir = r"d:\data\out"
pth = r"C:\Users\Priva\Documents\GeoScene\Projects\MyProject23\MyProject23.aprx"
aprx = arcpy.mp.ArcGISProject(pth)
mapnames = []
for i, m in enumerate(aprx.listMaps()):
print(f"{i} : {m.name}")
#mapnames.append(m.name)
service_name = m.name
sddraft_filename = service_name + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)
sd_filename = service_name + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)
# Create MapServiceDraft and set metadata and server folder properties
sddraft = arcpy.sharing.CreateSharingDraft("STANDALONE_SERVER", "MAP_SERVICE", service_name, m)
#sddraft.credits = "These are credits"
sddraft.description = "This is description"
sddraft.summary = "This is summary"
sddraft.tags = "tag1, tag2"
#sddraft.useLimitations = "These are use limitations"
#sddraft.serverFolder = "MyServerFolder"
sddraft.offline = True
sddraft.copyDataToServer = True
# Create Service Definition Draft file
sddraft.exportToSDDraft(sddraft_output_filename)
# Stage Service
print("Start Staging")
arcpy.server.StageService(sddraft_output_filename, sd_output_filename)
print("finish")
这里代码是针对某个工程内的,如果多个工程,可以自己修改代码
官方帮助参考
其他相关参数等相关资料可参考官方帮助内容进行修改。
https://pro.arcgis.com/en/pro-app/latest/arcpy/sharing/mapservicedraft-class.htm
https://community.esri.com/t5/python-questions/why-does-calling-listmaps-return-multiples-of-the/td-p/1128506