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);
Does your console give you any errors?
Can you also post your require and function, to see if you load the modules you need?
I have received no errors whatsoever. Here is my require and function (its in a custom widget):
define([ "dojo/_base/declare", "dojo/dom", "dojo/dom-construct", "dojo/on", "dojo/parser", "dojo/date/stamp", "esri/lang", "esri/layers/FeatureLayer", "esri/layers/CSVLayer", "esri/layers/GraphicsLayer", "esri/graphic", "esri/Color", "esri/symbols/SimpleMarkerSymbol", "esri/renderers/ClassBreaksRenderer", "esri/dijit/Search", "esri/tasks/query", "dijit/popup", "dijit/layout/ContentPane", "dijit/form/Form", "dijit/form/Button", "dijit/form/TextBox", "dijit/form/NumberTextBox", "dijit/form/DateTextBox", "dijit/form/Select", "dijit/_WidgetBase", "dijit/_TemplatedMixin", "dojo/text!./HonorsForm.html", "dojo/domReady!" ], function(declare, dom, domConstruct, on, parser, Stamp, esriLang, FeatureLayer, CSVLayer, GraphicsLayer, Graphic, Color, SimpleMarkerSymbol, ClassBreaksRenderer, Search, Query, popup, ContentPane, Form, Button, TextBox, NumberTextBox, DateTextBox, Select, _WidgetBase, _TemplatedMixin, template){