Override item names in legend from graphics layer in print task

8117
10
Jump to solution
02-06-2013 02:50 AM
JörgPossin
New Contributor III
Hi!

I added some graphics in a graphicLayer which works well in the browser web map and also in the pdf produced with the server print task. You can see the graphics in the pdf but in the legend you see the symbols but only the item names "Override 1" "Override 2" etc. Is there a possibilty to rename the item objects in the legend from the pdf?

Here is an example:

[ATTACH=CONFIG]21491[/ATTACH]

The other 2 items are not part of the graphics layer.
Tags (2)
1 Solution

Accepted Solutions
FrankMcLean
New Contributor III
Hi,

I can tell you what the underlying problem probably is, though we use the JS API.

Looking at the JSON sent to the print service, your graphics layer has a null renderer and your graphics features are symbolized.  The feature symbols are therefore overriding the renderer symbols and the map is giving them the friendly label of 'Override 1', 2, etc.

If you mess with the JSON to create a renderer such as:

        "renderer": {
         "type":"simple",
         "label": "My Label",
         "symbol":{
          "color":[0,0,0,128],
          "outline":{
           "color":[0,0,0,255],
           "width":0.75,
           "type":"esriSLS",
           "style":"esriSLSSolid"
          },
          "type":"esriSFS",
          "style":"esriSFSSolid"
         }
        }

And then comment out the feature symbol (or else you'll still override), submitting the JSON to the print task will show 'My Label' in the Legend.

I'm not sure what the implications of all this are, either in Flex or JS, but if this god-like insight :rolleyes: is of any help, please post.

Thanks,

Frank

View solution in original post

10 Replies
JörgPossin
New Contributor III
Has no one an idea? 😞
0 Kudos
BenSher1
New Contributor
Did you ever figure this out? I'm having the same issue.
0 Kudos
JörgPossin
New Contributor III
Did you ever figure this out? I'm having the same issue.


No, I have no idea how to solve the problem. I tried to find an attribute in the graphics object which is used in the print service as name in the legend but it does not work. rlt.typ should be the legend name:

graphic = new Graphic(); 
graphic.geometry = new MapPoint(rlt.localX, rlt.localY, usedSRS);
graphic.symbol = new PictureMarkerSymbol(markerImage);
graphic.toolTip = rlt.bezeichnung;
graphic.name = rlt.typ;
      
graphic.accessibilityDescription = rlt.typ;
graphic.accessibilityName = rlt.typ;
graphic.className = rlt.typ;
graphic.automationName = rlt.typ;


I save the graphics in an own graphicsLayer and added this layer to the map. I also saved the graphics in the defaultGraphicsLayer from the map but in this way no items appear in the legend. I think this behaviour is normal because items in the defaultGraphicslayer are not considered in the legend.
0 Kudos
FrankMcLean
New Contributor III
Hi,

I can tell you what the underlying problem probably is, though we use the JS API.

Looking at the JSON sent to the print service, your graphics layer has a null renderer and your graphics features are symbolized.  The feature symbols are therefore overriding the renderer symbols and the map is giving them the friendly label of 'Override 1', 2, etc.

If you mess with the JSON to create a renderer such as:

        "renderer": {
         "type":"simple",
         "label": "My Label",
         "symbol":{
          "color":[0,0,0,128],
          "outline":{
           "color":[0,0,0,255],
           "width":0.75,
           "type":"esriSLS",
           "style":"esriSLSSolid"
          },
          "type":"esriSFS",
          "style":"esriSFSSolid"
         }
        }

And then comment out the feature symbol (or else you'll still override), submitting the JSON to the print task will show 'My Label' in the Legend.

I'm not sure what the implications of all this are, either in Flex or JS, but if this god-like insight :rolleyes: is of any help, please post.

Thanks,

Frank
ChristopherJohnson1
Occasional Contributor II

Hi, Frank. I know that it has been a while since you posted this, but I just wanted some clarification.

Do you mean to modify the JSON in the "Web_Map_as_JSON" object?

And where did you mean to comment out the "feature symbol".  In that same object?

Thanks...Chris

0 Kudos
FrankMcLean
New Contributor III

Hi Christopher,

I'm so sorry - I just got notified of your reply.  Yes, that's exactly the JSON I meant.  And as for commenting out the feature symbol, it's been so long since I've done this...  If you pretty format Web_Map_as_JSON, I'm pretty sure you'll see the feature symbol I'm talking about.  Sorry I can't be more detailed.  Just either remove that from the feature, or literally insert commenting around it in the text.  Your aim is simply to get rid of its overriding effects.

Frank

ChristopherJohnson1
Occasional Contributor II

No worries...thanks!

0 Kudos
JosephDavies
New Contributor III

Thanks for this Frank!

I was having trouble changing the legend label (override 1) generated by the print task for a jimu/DrawBox graphic which is being used to show the 'area of interest' in the map.

If anyone else has trouble modifying the legend for DrawBox layers, here is the code I used in the "draw-end" event of the drawBox:

      var simpleJson = {
        "type":"simple",
        "label": "Area de Interés",
        "symbol":{
          "color": [
            0,
            112,
            255,
            64
          ],
          "outline": {
            "color": [
              0,
              0,
              0,
              255
            ],
            "width": 1,
            "type": "esriSLS",
            "style": "esriSLSSolid"
          },
          "type": "esriSFS",
          "style": "esriSFSSolid"
        }
      };
      var drawboxRenderer = new SimpleRenderer(simpleJson);
      this.drawBox.drawLayer.graphics[0].symbol = null;
      this.drawBox.drawLayer.graphics[0]._graphicsLayer.setRenderer(drawboxRenderer);
      this.drawBox.drawLayer.graphics[0]._layer.setRenderer(drawboxRenderer);

Hopefully this might be helpful for somebody,

Cheers,

Joe

FrankMcLean
New Contributor III

Thanks Joe.  I'm literally amazed that this is still a thing. 🙂  I don't work on this stuff anymore, but I remember seeing the webmap functionality when it was first introduced and being blown away.  I expected to have to knock some rough edges like this off in the early versions, but it seems like Esri have left this to wither.  Bit of a shame, cos we did some cool (for us) stuff with it.  🙂

0 Kudos