# Imports import arcpy import sys import os import uuid import ast # used to work with user defined extent import json # used to work with the web map json string # Snip... # Input WebMap json Web_Map_as_JSON = arcpy.GetParameterAsText(0) #Snip (insert other parameters) #Extra parameter - Extent Extent = ast.literal_eval(arcpy.GetParameterAsText(5)) _Extent = arcpy.Extent(Extent.get("xmin"), Extent.get("ymin"), Extent.get("xmax"), Extent.get("ymax")) #Extra parameter - Scale Scale = float(arcpy.GetParameterAsText(6)) # modify Web_Map_as_JSON so that the web map scale matches the scale provided. Web_Map_Dict = json.loads(Web_Map_as_JSON) Web_Map_Dict["mapOptions"]["scale"] = Scale Web_Map_as_JSON = json.dumps(Web_Map_Dict) # Snip (getting file location of templateMxd) # Convert the WebMap to a map document result = arcpy.mapping.ConvertWebMapToMapDocument(Web_Map_as_JSON, templateMxd) mxd = result.mapDocument # Snip (do other things to the map as needed) # Reference the data frame that contains the webmap # Note: ConvertWebMapToMapDocument renames the active dataframe in the template_mxd to "Webmap" df = arcpy.mapping.ListDataFrames(mxd, 'Webmap')[0] # Update the extent of the map to match the extent passed through the service. df.panToExtent(_Extent) # Snip (Do whatever else you need to the map, before serving it out.)
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.