MDonnellyesriaustralia-com-au-esridist

map.graphics is null

Discussion created by MDonnellyesriaustralia-com-au-esridist Employee on Nov 24, 2010
Latest reply on Dec 6, 2010 by khutchins-esristaff
Hi,

I'm trying to draw a point symbol over my base map layer. I'm using the following code but firebug tells me that map.graphics is null. I successfully use the map object for many other operations, it just doesn't seem to have a graphics object associated with it:

      dojo.require("dojo.parser");
      dojo.require("esri.map");
      dojo.require("esri.dijit.editing.Editor-all");
      dojo.require("dijit.layout.ContentPane");
      dojo.require("dijit.layout.BorderContainer");
      dojo.require("dijit.layout.TabContainer");  
      dojo.require("esri.dijit.Scalebar");   
      dojo.require("esri.tasks.geometry");
      dojo.require("esri.toolbars.draw"); 
      dojo.require("esri.graphic");
      dojo.require("esri.layers.graphics");
.
.
.
var initialExtent = new esri.geometry.Extent({"xmin":xmin,"ymin":ymin,
            "xmax":xmax,"ymax":ymax,"spatialReference":{"wkid":102100}}).expand(3.0);
var map = new esri.Map("map", { extent: initialExtent, slider: true, nav: false, logo: false });
.
.
.
var pt = new esri.geometry.Point(upEast,upNorth,map.spatialReference)
var sms = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 10, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new  dojo.Color([255,0,0]), 1), new dojo.Color([0,255,0,0.25]))
var attr = {"XCoord":upEast,"YCoord":upNorth};
var infoTemplate = new esri.InfoTemplate("Upstream","Latitude: ${YCoord} <br/>Longitude: ${XCoord}");
var graphic = new esri.Graphic(pt,sms,attr,infoTemplate);
map.graphics.add(graphic);

Outcomes