harshana

map.graphics.add can not identify the graphic object

Discussion created by harshana on May 23, 2012
Latest reply on May 27, 2012 by harshana
Hi Mates,

I am populating rings for a Geometry json object and creating a Graphic object to add for the map. Code is looks like below,

function addGraphicToMap(geometry,ordernum,infoTemplate) {
   var new_extent = null;
   var symbol = symbols[ordernum-1];
   var graphicObj = new esri.Graphic(geometry, symbol);

   graphicObj.setGeometry(geometry);
   graphicObj.setSymbol(symbol);
   graphicObj.setAttributes( {"ORDER_NUM":ordernum});
   graphicObj.setInfoTemplate(infoTemplate);
   map.graphics.add(graphicObj);
   var old_extent = geometry.getExtent();
   if(i == 0)
   {
       new_extent = old_extent;
   }
   else
   {
      new_extent = new_extent.union(old_extent);
   }
}

But when I try to add graphicObj to map it gives me a error saying, : TypeError: 'graphicObj' is undefined

In my geometry object I have only rings as attribute and I guess that enough to create a Graphic know?

Thanks.

Outcomes