2

I have a Javascript function that creates a GraphicsLayer, adds some features to it, and then adds the layer to my ArcGIS Web Map. When I use the Print Widget to print my map I see the layer show up in the Legend labeled "Overrride 1". Is there a way to add a title or name to a GraphicsLayer so that it will be properly rendered by the print task?

Here's a plunk to demonstrate: http://plnkr.co/edit/DM7U7H

  • I see that I am getting downvoted although I am not sure why. In the interest of asking better questions in the future, can anyone explain what's wrong with this question? – Chris May 6 '16 at 13:08
  • 1
    I agree with @Chris, why is this getting downvoted? It's not a perfect question, but it can certainly help someone solve their problem – Goldorak84 Apr 11 '17 at 15:51
  • I am having this exact same issue, except the feature labels showing up in my layout legend are coming from a Directions widget being served by an ESRI sample server. Does this mean that I have no control over the feature labels showing as pointLayer, polylineLayer, Override 1, and Override 2? Check out the screenshot below: ![enter image description here](i.stack.imgur.com/NyKJh.png) – druZ Jan 31 '18 at 15:41
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review – gisnside Jan 31 '18 at 16:03
1

I figured out a solution to this problem. I could not find a way to get a GraphicsLayer to be properly labeled but when I switched to a FeatureLayer instantiated with my own feature collection I was able to configure a renderer that rendered the print service PDF correctly. Here's some simplified code:

var featureCollection = {
    "layerDefinition": {
      "geometryType": "esriGeometryPoint",
      "objectIdField": "ObjectID",
      "drawingInfo": {
        "renderer": null
      },
      "fields": [{
        "name": "type",
        "alias": "type",
        "type": "esriFieldTypeString"
      }]
    },
    "featureSet": {
      "geometryType": "esriGeometryPolyline",
      "features": []
    }
  };

  var projectLayer = new FeatureLayer(featureCollection, {
    id: 'Projects',
    infoTemplate: new InfoTemplate()
  });

  var projectColor = new esri.Color([1, 30, 169, 1]);
  var lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, projectColor, 3);
  var pointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 10,
    new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, projectColor, 1),
    projectColor
  );
  var renderer = new UniqueValueRenderer(lineSymbol, "type");
  renderer.addValue("line", new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, esri.Color([1, 30, 10, 1]), 3));
  renderer.addValue("line2", new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, esri.Color([1, 30, 169, 1]), 3));
  renderer.addValue("point", pointSymbol);

  projectLayer.setRenderer(renderer);

  map.addLayer(projectLayer);

It would have been nice to just create the feature layer with the URL constructor but my requirements were to take two server feature layers and combine them into a single client side layer. After adding the layer I used

projectLayer.applyEdits(<arrayOfGraphics>, null, null);

to add features. Here is another plunker demonstrating my solution: http://plnkr.co/edit/GNcmhK?p=info

1

Another way to side step this problem is to add the graphic to map.graphics. map.graphics does not show up on the legend in the print service. So the "override" label won't show up in the legend.

Here's the demo plunker : http://plnkr.co/edit/vjaffQ?p=preview

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.