FeatureLayer and GraphicsLayer  not printing

1414
2
Jump to solution
01-09-2013 11:10 AM
DanielSanders
New Contributor III
I have a multi-layered map that I need to print. After adding my base layer, I add a FeatureLayer that displays a set of regions or districts that are color-coded using a ClassBreaksRenderer. (The FeatureLayer gets its geometric data from a standard ArcGIS service and its classification data from a SQL query.)  Then I add a set of labels (Graphics using a TextSymbol) to a GraphicsLayer. All of the shapes and text will show on my map but refuse to print using the esri.dijit.Print object. If, however, I use a SimpleRenderer in place of a ClassBreaksRenderer, the FeatureLayer will print.

Is this by design or is there something I am doing wrong?

I've created a jsFiddle here that will demonstrate the issue I'm having.

Some of my key definitions follow:

Feature layer:
// Create the feature layer var districtShadeLayerDefinition = {  "geometryType": "esriGeometryPolygon",  "objectIdField": "ObjectID",  "fields": [{   "name": "ObjectID",   "alias": "ObjectID",   "type": "esriFieldTypeOID"  },{   "name": "NAME",   "alias": "Name",   "type": "esriFieldTypeString"  },{   "name": "AreaValue",   "alias": "Area Value",   "type": "esriFieldTypeDouble"  }] } ; app.districtShadeValuesSet = []; var districtShadeCollection = {  "layerDefinition": districtShadeLayerDefinition,  "featureSet": {   "features": app.districtShadeValuesSet,   "geometryType": "esriGeometryPolygon"  } }; app.districtShadeLayer = new esri.layers.FeatureLayer(districtShadeCollection, {id: 'valueLayer', infoTemplate: app.infoTemplate, mode:esri.layers.FeatureLayer.MODE_SNAPSHOT, outFields:"*"}); app.map.addLayer(app.districtShadeLayer);


Class breaks renderer:
// create default symbols and colors var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID  , new dojo.Color([255, 255, 255, 0.35]), 1), new dojo.Color([125, 125, 125, 1])); var renderer = new esri.renderer.ClassBreaksRenderer(symbol, "AreaValue"); var selectedClasses = 3; var colorList = ["#F00","#0F0","#00F"];  // create the renderer for (var i = 0; i < selectedClasses; i++) {  var lowerBound = app.classBreaks;  var breakValue = app.classBreaks[i + 1];  var adjustedBreakValue;  if (i < selectedClasses - 1) {   // calculate the upper bound for this break, since class breaks are >= min and < max   adjustedBreakValue = app.classBreaks[i + 1];  }  else {   adjustedBreakValue = Infinity;  }  renderer.addBreak(lowerBound, adjustedBreakValue, new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color(colorList))); } app.districtShadeLayer.setRenderer(renderer);


Any assistance you can provide would be very much appreciated.
0 Kudos
1 Solution

Accepted Solutions
ShreyasVakil
Occasional Contributor II
I did a lot of research into this and finally found that at this point printing fails when it sees the last break as 'Infinity'. Instead try assigning a much greater value in place of Infinity:

Change this line:
adjustedBreakValue = Infinity;


to something say:

adjustedBreakValue = 200000;



Let me know if it works.

View solution in original post

0 Kudos
2 Replies
ShreyasVakil
Occasional Contributor II
I did a lot of research into this and finally found that at this point printing fails when it sees the last break as 'Infinity'. Instead try assigning a much greater value in place of Infinity:

Change this line:
adjustedBreakValue = Infinity;


to something say:

adjustedBreakValue = 200000;



Let me know if it works.
0 Kudos
DanielSanders
New Contributor III
Thanks! The FeatureLayer and ClassBreaksRenderer print now that I've put a real value for the upper limit! However, the class breaks seem to be interpreted differently on the browser and server. I can force the JavaScript version to look like the printed version by using "renderer.setMaxInclusive(true)". Is there some setting I can use to make the printed version look like the JavaScript version instead?

Also, the GraphicsLayer still is not printing. Is there something I should try using instead?

Edit: I just verified that we need the maximum value to be inclusive, so this function works for our purposes. I still need to make some changes to the GraphicsLayer though.Thanks for all your help!
0 Kudos