Select to view content in your preferred language

Print a graphics layer containing points and texts

1121
2
Jump to solution
10-04-2013 09:55 AM
JasonZou
Frequent Contributor
I am using PrintTask in JSAPI 3.6 for the map print. Everything works fine until I want to print a map with a graphics layer that contains points AND texts. The print result varies based on the order in which the points and texts are added to the graphics layer.

For simplicity, let's draw one point first and then one text on the map. On the printout, the point will be displayed correctly, but the text will be displayed using the same symbol as the point. No text string. Ok, let's switch the order. Add the text first and then the point. This time on the printout, the text will be displayed correctly, but the point disappears!

I have tested the behavior via my app and the REST service endpoint, and got the same result. Below is the sample Web_Map_as_JSON string for test for point first then text.

{     "mapOptions": {         "showAttribution": true,         "extent": {             "xmin": -10626238.11274791,             "ymin": 3299637.0692294897,             "xmax": -9574464.603543935,             "ymax": 3846926.191751325,             "spatialReference": {                 "wkid": 102100             }         },         "spatialReference": {             "wkid": 102100         },         "scale": 2311162.2171550025     },     "operationalLayers": [{         "id": "Ocean",         "title": "Ocean",         "opacity": 1,         "minScale": 591657527.591555,         "maxScale": 9027.977411,         "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer"     }, {         "id": "Boundaries",         "title": "Boundaries",         "opacity": 1,         "minScale": 0,         "maxScale": 0,         "url": "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer",         "visibleLayers": null,         "layers": []     }, {         "id": "map_graphics",         "minScale": 0,         "maxScale": 0,         "featureCollection": {             "layers": [{                 "layerDefinition": {                     "name": "pointLayer",                     "geometryType": "esriGeometryPoint"                 },                 "featureSet": {                     "geometryType": "esriGeometryPoint",                     "features": [{                         "geometry": {                             "x": -10069165.050605573,                             "y": 3702001.586122638,                             "spatialReference": {                                 "wkid": 102100                             }                         },                         "symbol": {                             "color": [0, 255, 0, 191],                             "size": 7.5,                             "angle": 0,                             "xoffset": 0,                             "yoffset": 0,                             "type": "esriSMS",                             "style": "esriSMSSquare",                             "outline": {                                 "color": [0, 0, 0, 255],                                 "width": 1,                                 "type": "esriSLS",                                 "style": "esriSLSSolid"                             }                         }                     }, {                         "geometry": {                             "x": -10056323.629853662,                             "y": 3658585.35405666,                             "spatialReference": {                                 "wkid": 102100                             }                         },                         "symbol": {                             "color": [0, 0, 0, 255],                             "type": "esriTS",                             "angle": "0",                             "xoffset": 0,                             "yoffset": 0,                             "text": "Teest Text",                             "decoration": "none",                             "rotated": false,                             "kerning": true,                             "font": {                                 "size": 16,                                 "style": "italic",                                 "variant": "normal",                                 "weight": "bold",                                 "family": "Arial"                             }                         }                     }]                 }             }]         }     }],     "exportOptions": {         "outputSize": [800, 1100],         "dpi": 96     } }


Does anybody else experience the same problem or only me? Any workaround?

Thanks.
0 Kudos
1 Solution

Accepted Solutions
BenFousek
Deactivated User
Jason,
I ran into this problem awhile ago. I think it's a rendering issue with server mixing "esriSMS" and "esriTS" in the same collection. Ultimately, I ended up with separate layers for geometry types including a layer for text and one marker symbols. In my case I was working on a full map annotation module for drawing on the map, editing geometry, stylizing, etc. From a user perspective mixing up the geometry types on a single layer was problematic. So I went with separate layers from top to bottom: text, markers, points, polylines, polygons. I added functionality to move graphics to the back and front on a specific geometry layer. Makes it easy to select graphics for editing and styling, and users like it. As a bonus the print issue was resolved. The only drawback is if the concept involves different geometry types in different top to bottom positions. My users are doing some pretty intense markup and it seems to work fine, and I think the prints look better anyway.

View solution in original post

0 Kudos
2 Replies
BenFousek
Deactivated User
Jason,
I ran into this problem awhile ago. I think it's a rendering issue with server mixing "esriSMS" and "esriTS" in the same collection. Ultimately, I ended up with separate layers for geometry types including a layer for text and one marker symbols. In my case I was working on a full map annotation module for drawing on the map, editing geometry, stylizing, etc. From a user perspective mixing up the geometry types on a single layer was problematic. So I went with separate layers from top to bottom: text, markers, points, polylines, polygons. I added functionality to move graphics to the back and front on a specific geometry layer. Makes it easy to select graphics for editing and styling, and users like it. As a bonus the print issue was resolved. The only drawback is if the concept involves different geometry types in different top to bottom positions. My users are doing some pretty intense markup and it seems to work fine, and I think the prints look better anyway.
0 Kudos
JasonZou
Frequent Contributor
Hi Ben,

Your approach works great! So far, that might be the best workaround for the print issues I have experienced.

I like to summarize the print issues we experienced related to the JSAPI. Two main issues:

  1. If one graphics layer contains points using any MarkerSymbol and texts (texts are point spatial type but using TextSymbol. For simplicity, I just use points as spatial features, and texts as label or informative message), the printout using PrintTask will vary depending on the order points and texts are added to the layer. If points are added first, the texts will be drawn using the point symbol. If texts added first, the points will disappear on the printout.



  2. If one graphics layer contains mixed spatial types, like using drawing tool to draw polygons, lines, points, multipoints and texts, no matter what order they are added, the PrintTask will re-shuffle all the graphics and put them into four sub-layers: pointLayer, polylineLayer, polygonLayer and multipointLayer. These four sub-layers will be added to the printout page in the order from top to bottom as multipointLayer, polygonLayer, polylineLayer and pointLayer. The result will be all polygons will be on top of lines and points even if you added the points and lines on top of polygons.



I firmly believe they are the bugs. Hopefully ESRI can recognize these and correct them in the future release. For the second issue, I don't quite understand why all the graphics need to be shuffled into four categories. Why not just add and render each graphic as it is added to the layer?
0 Kudos