Select to view content in your preferred language

Best method for forming JSON for Export Web Map (Printing) task

7870
11
08-24-2012 12:36 PM
DavidSchuster1
Deactivated User
Hi,

Can anyone suggest the best way to generate the JSON ("Web_Map_as_JSON" parameter) for a call to the REST API for the Export Web Map printing task?  I need to be able to programatically generate the JSON based on a number of changing configuration options.

It seems like I have a few options:
- Manually construct the JSON string myself.
- Create my own set of classes to represent each parameter (mapOptions, operationalLayers, etc), and use JSON serialization.
- Does ESRI already provide a class library that supports this?  ArcGIS Runtime for WPF perhaps?

Here's what I'm trying to do:
I want to create a .NET 3.5 class library (no user interface) that can be called repeatedly by the rest of my application whever a static map image is needed.   The caller will pass in some feature identifier, and my library will use the REST APIs to locate the feature and return the map image zoomed into the feature.

Thanks!
Tags (2)
11 Replies
KevinGooss
Regular Contributor
DSMapper - our apps sound strikingly similar. In my case I'm pairing the ags generated map with an SSRS report and merging them into a single pdf like you do with your multiple maps.
Unlike your app though I'm thinking of moving toward having a map in mine so that i can allow the user to further refine the mapping print output before it gets generated. But there will always be a version that has no mapping capabilities because it is just not relevant to the workflow.
0 Kudos
TanuHoque
Esri Regular Contributor
Sorry for a long silence from my side. In case you have not figured out this yet, the following seems like a good solution to your problem....

Seems like with ArcGIS API for Silverlight, you may have a luck of using ArcGIS Server 10.1's Printing Service with Web API's Print Task without having a map on your web application.

Apparently the API has an overloaded constructor for PrintParameters class that allows you to create a PrintParameters object only with layers and extent, no map is needed.

Once you get that you can pass that as a parameter to Execute() function of Print Task to get the output.

PrintTask printTask = new PrintTask("http://myServer/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export Web Map Task");
ArcGISDynamicMapServiceLayer lyr = new ArcGISDynamicMapServiceLayer();
lyr.Url = "http://myServer/arcgis/rest/services/myMapService/MapServ1er";
ObservableCollection<Layer> colLayers = new ObservableCollection<Layer>();
colLayers.Add(lyr);

Envelope extent = new Envelope(<xmin>, <ymin>, <xmax>, <ymax>);
PrintParameters PrintParams = new PrintParameters(colLayers, extent);

... // set layoutOptions [optional]
... // set exportOptions [optional]

printTask.ExecuteAsync(PrintParams);



This will prevent you from:

  • coming up your own set of classes or

  • manual construction of json string in your code


Please let me know if that works for you.
0 Kudos