Select to view content in your preferred language

Printing web maps - rectangular PictureMarkerSymbol graphics incorrectly scaled....

3280
10
02-07-2013 09:22 AM
by Anonymous User
Not applicable
Hello all,

I think this is a Python issue, because I believe it occurs at the point when the arcpy.mapping.ConvertWebMapToMapDocument() function is used to translate Web_Map_as_JSON data submitted by web applications into map documents.  The problem I have encountered (using server 10.1 SP1), is that if a graphic has a picture marker symbol using an image that is wider than it is tall, the same graphic in a printed copy of the web map will appear to be scaled up in size.  It looks like it gets scaled by a factor equal to the ratio of the width to the height.

It's easier to explain with samples: Open the print task web map from the help documentation (http://help.arcgis.com/en/webapi/javascript/arcgis/samples/widget_print_esri_request/index.html), then open the browser's developer console in (chrome/IE) or Firebug in Firefox, and execute this code:

with (app.map.graphics)
{
    clear();
    add(new esri.Graphic(
        new esri.geometry.Point(-13074375.841524666,4016210.98226017,app.map.spatialReference),
        new esri.symbol.PictureMarkerSymbol("http://i48.tinypic.com/jzjid.png",43,11))); // src img size: 43x11
    add(new esri.Graphic(
        new esri.geometry.Point(-13074075.841524666,4016210.98226017,app.map.spatialReference),
        new esri.symbol.PictureMarkerSymbol("http://i50.tinypic.com/33uq242.png",43,43))); // src img size: 43x43
    add(new esri.Graphic(
        new esri.geometry.Point(-13073775.841524666,4016210.98226017,app.map.spatialReference),
        new esri.symbol.PictureMarkerSymbol("http://i46.tinypic.com/123midj.png",11,43))); // src img size: 11x43
}


You should see three icons on the map with varying dimensions.  Now try printing a map...you will see the problem I described with the first icon on the left, that is originally 43px wide and 11px high.  The resulting size I believe works out to more or less the equivalent of: 43px high, and (43*(43/11))px wide.

Now try the following:

with (app.map.graphics)
{
    clear();
    add(new esri.Graphic(
        new esri.geometry.Point(-13074375.841524666,4016210.98226017,app.map.spatialReference),
        new esri.symbol.PictureMarkerSymbol("http://i48.tinypic.com/jzjid.png",43/(43/11),11/(43/11)))); // src img size: 43x11
    add(new esri.Graphic(
        new esri.geometry.Point(-13074075.841524666,4016210.98226017,app.map.spatialReference),
        new esri.symbol.PictureMarkerSymbol("http://i50.tinypic.com/33uq242.png",11,43))); // src img size: 43x43
    add(new esri.Graphic(
        new esri.geometry.Point(-13073775.841524666,4016210.98226017,app.map.spatialReference),
        new esri.symbol.PictureMarkerSymbol("http://i46.tinypic.com/123midj.png",22,43))); // src img size: 11x43
    add(new esri.Graphic(
        new esri.geometry.Point(-13074375.841524666,4015910.98226017,app.map.spatialReference),
        new esri.symbol.PictureMarkerSymbol("http://i50.tinypic.com/33uq242.png",11,11))); // src img size: 43x43
    add(new esri.Graphic(
        new esri.geometry.Point(-13074075.841524666,4015910.98226017,app.map.spatialReference),
        new esri.symbol.PictureMarkerSymbol("http://i50.tinypic.com/33uq242.png",43,11))); // src img size: 43x43
    add(new esri.Graphic(
        new esri.geometry.Point(-13073775.841524666,4015910.98226017,app.map.spatialReference),
        new esri.symbol.PictureMarkerSymbol("http://i46.tinypic.com/123midj.png",11,86))); // src img size: 11x43
}


The top-left icon is now much smaller - I have shrunk the icon by the same factor that it appears to be expanded by when printed.  I've also tried a few other variations with the other graphics (with source images that have 43x43 and 11x43 dimensions).  Now print another map...it appears now that the top-left icon has been scaled back to its original size.  With the remaining examples, you'll see that the dimensions are not the same in the output PDF, unless the size of the graphic is the same aspect ratio of the source image graphic (e.g., the bottom-left graphic).

I could try to avoid this problem by ensuring that I use square graphics in my application, with transparent backgrounds for rectangular symbols.  However, that will result in relatively large areas in the web-map display that will resolve mouse click/move events to the corresponding point graphic.

Alternatively, I could work around this in client-side code to alter the symbols before calling a print task...or I could create a custom print task that parses Web_Map_as_JSON text and scales symbol that I know will be affected by this before using the JSON text to create a map document.

Would anyone else here know of this problem, and/or have any suggestions?
Tags (2)
0 Kudos
10 Replies
JeffMoulds
Esri Contributor
That sample doesn't use ConvertWebMapToMapDocument (or Python at all), so you might get better results if you post it on the JavaScript API Forum.

Or, do you have a web map json string, that, when passed into ConvertWebMapToMapDocument, followed by arcpy.mapping.ExportToPDF, generates the problematic output?
0 Kudos
by Anonymous User
Not applicable
The steps I outlined uses the sample application from the help documentation, which uses the JavaScript API PrintTask to generate the request containing the web map converted to JSON text (you can see this if you monitor the network request in the browser's development console).  I've used the out-of-the-box Print service, as well as a couple custom print tasks published from python scripts.

When I get the chance, I'll see if I can wrap this up in a simple offline python script, using the same JSON text that gets produced by following the steps I outlined above.
0 Kudos
by Anonymous User
Not applicable
I've attached a sample Python script.  It contains two sample Web_Map_as_JSON string produced by the same steps I described above.  When the PDF is generated, the graphics appear the same as before...and they show the same size differences as before.  You'll have to edit the script to specify the output location of the PDFs - it's also pointing to one of the default template map documents that come with ArcGIS for server.

I used the web map interface to illustrate this initially, because it lets you see what the original sizes of the graphics before the web map is converted to JSON and submitted to the print task on a server.  The attached script will allow you reproduce the problem using only python.
0 Kudos
JeffMoulds
Esri Contributor
Do you have ArcGIS Desktop? If you symbolize a point layer with those same picture marker symbols (for example http://i46.tinypic.com/123midj.png), do you get the results you expect on screen and on output pdf?
0 Kudos
by Anonymous User
Not applicable
If I use the same graphics for picture marker symbols in ArcMap, then export to PDF, the result looks fine (no obvious changes to the size of the graphic in the PDF output).
0 Kudos
JeffMoulds
Esri Contributor
I am not seeing any difference between the ArcMap UI and the python script. Can you send me two PDFs - one generated from the python script that has the erroneous output, and one generated from ArcMap which looks fine. Also, if you output to JPG from the python script, does it also show the problem?

I am assuming what you are seeing is that the json supports a height and width property, but the Print Task and  ConvertWebMapToMapDocument only supports a size property. And it takes the height value and scales the width proportionally. Anyways, once I see the PDFs, I can see if that's whats going on. Thanks.
0 Kudos
by Anonymous User
Not applicable
Following the steps in my original post should give you a PDF that demonstrates the problem directly from the PrintTask service from the arcgis online sample server that supports the demo.

I've attached four new files - a PDF/JPG from produced from the standalone python script, and the same generated by the online sample server (follow this link to try it yourself via the REST interface).

Your description of the root cause of the problem sounds about right, though don't know what the best method would be to deal with it.
0 Kudos
JeffMoulds
Esri Contributor
Please send a PDF of the output from the ArcMap UI that you state is ok so that I can compare it to the erroneous output. Perhaps the ratio between height and size is so small that I am not able to visualize your problem.
0 Kudos
by Anonymous User
Not applicable
See attached - the graphics in ArcMap UI look the same as in the WebMap UI *before* printing.  When the Web map is converted to JSON, the output from the PrintTask/Python will alter the size of the left-hand graphic from the first set.  Exporting from ArcMap does not have this effect.
0 Kudos