Label Size When Print Maps with JSAPI 4.1

1058
2
09-26-2016 02:56 PM
AnthonyPelikan1
New Contributor

The new library features for jsapi 4.1 are really wonderful and we appreciate the hardwork that has gone into it. The printing function has been a vital request for our end users.

So far we've had good success implementing the API, however when we do print our labels for our graphic layers are showing up with a font size in excess of 36 points, unfortunately dominating the screen.

We are passing in the mapView object and printTemplate to the Print parameters object. 

Any thoughts or suggestions on this would be helpful.

Thank yoU!

0 Kudos
2 Replies
FC_Basson
MVP Regular Contributor

I think you should start by having a look at the Web_Map_as_JSON object being passed to the server in the Print Task execute request.  The text should be contained by a graphicsLayer object with a text symbol defined, where the text size should be an integer value e.g.

{

  • "id":"graphicsLayer5",
  • "opacity":1,
  • "minScale":0,
  • "maxScale":0,
  • "featureCollection":{
    • "layers":[
      1. {
        • "layerDefinition":{
          • "name":"textLayer",
          • "geometryType":"esriGeometryPoint"
          },
        • "featureSet":{
          • "geometryType":"esriGeometryPoint",
          • "features":[
            1. {
              • "geometry":{
                • "x":2549897.66787728,
                • "y":-3885519.2773505934,
                • "spatialReference":{
                  • "wkid":102100
                  }
                },
              • "symbol":{
                • "color":[
                  1. 255,
                  2. 255,
                  3. 255,
                  4. 255
                  ],
                • "type":"esriTS",
                • "verticalAlignment":"baseline",
                • "horizontalAlignment":"left",
                • "angle":0,
                • "xoffset":3.75,
                • "yoffset":3.75,
                • "text":"graphic-0",
                • "rotated":false,
                • "kerning":true,
                • "font":{
                  • "size":12,
                  • "style":"normal",
                  • "variant":"normal",
                  • "weight":"normal",
                  • "family":"Arial"
                  }
                }
              }
            ]
          }
        }
      ]
    }

}

AnthonyPelikan1
New Contributor

Thank you FC Basson.


I did add the rest of the font object fields, but unfortunately I did not* have success. 

Only when I changed the font size to 1 and the offset from -25px (my settings) to -1px did I get the result I was looking for. 

I parsed through the layer collection from both the map and the mapView and found that in both cases the font and offset where what I had set them when I created the graphics layer. 

The graphics layer I have is interesting in that it is a collection of two symbol types: textSymbol and markerPictureSymbol (both 2D only). Would it be possible that since I have a single graphics layer with two types of symbols that it is interfering with the server side processing?

Thanks again to you and to anyone else readying this!

0 Kudos