AnsweredAssumed Answered

Map not loading graphics layer

Question asked by npeckman on Jul 23, 2015
Latest reply on Jul 23, 2015 by npeckman

I am having unexpected trouble getting my map to display a graphics layer created in the program. It displays a feature layer correctly, and I don't understand why it won't display with graphics layer. I've done extensive console logging: the "layer-add-result" event fires without error and the object contains the correct layer. However, the map object has the same layers and graphics before and after the layer addition (only default layer). There is no change to the map object, but no error either. The graphics layer has the correct features (obtained from a feature set from a query, if that matters). Here's a little of my code (cityArray is an array of arrays, where each sub array has all features in the same city):

 

 

var cityDisplay = new GraphicsLayer();
for(var idx = 0; idx < cityArray.length; idx++){
     var g = new Graphic(cityArray[idx][0].geometry, null, {numOfEvents: cityArray[idx].length, Events: cityArray[idx]});
     cityDisplay.add(g);
}
var symbol = new SimpleMarkerSymbol();
symbol.setColor(new Color([150, 150, 150, 0.5]));
var renderer = new ClassBreaksRenderer(symbol, "numOfEvents");
renderer.addBreak(0, 3, new SimpleMarkerSymbol().setColor(new Color([56, 168, 0, 0.5])));
renderer.addBreak(3, 25, new SimpleMarkerSymbol().setColor(new Color([139, 209, 0, 0.5])));
renderer.addBreak(25, 50, new SimpleMarkerSymbol().setColor(new Color([255, 255, 0, 0.5])));
renderer.addBreak(50, 100, new SimpleMarkerSymbol().setColor(new Color([255, 128, 0, 0.5])));
renderer.addBreak(100, Infinity, new SimpleMarkerSymbol().setColor(new Color([255, 0, 0, 0.5])));
cityDisplay.setRenderer(renderer);
map.on("layer-add-result", function(err){
     console.log(err);
});
map.addLayer(cityDisplay);

Outcomes