AnsweredAssumed Answered

problem with map.graphics.add(graphic);

Question asked by dexconor on Apr 29, 2014
Latest reply on May 1, 2014 by dexconor
Hi all,

function getLocRes(results) {
 //map.graphics.clear();
 var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([80, 0, 0]), 2), new dojo.Color([80, 0, 0, 0.5]));
 var combinedExtent = new esri.geometry.Extent();
 console.log("er",results.features.length);
 for (var i = 0;i < results.features.length; i++) {console.log("i=",i);
  var polyGraphic = new esri.Graphic(results.features[i], symbol);
  console.log("i=",polyGraphic);
  polyGraphic.setSymbol(symbol);
  //map.graphics.add(graphic);
 }
 combinedExtent = esri.graphicsExtent(results.features);
 map.setExtent(combinedExtent, true);
}


this function is working sort of  but when I enable either
map.graphics.clear();
or
map.graphics.add(graphic);
it stops where the code is
console.log("i=",i);
this shows
only 0 when map.graphics.add(graphic); is on
if not it doesn't add graphic but shows console.log("i=",i); result until the end

Am I missing something here that map.graphics.add(graphic); shouldn't work?

dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
dojo.require("esri.dijit.Popup");
dojo.require("esri.dijit.Legend");
dojo.require("esri.layers.agsdynamic");

dojo.require("esri.layers.ArcGISTiledMapServiceLayer");
dojo.require("dijit.dijit");
dojo.require("esri.tasks.find");//search     

dojo.require("esri.arcgis.utils");
dojo.require("esri.dijit.Print");
dojo.require("dojox.grid.DataGrid");

dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dijit.form.Button");
dojo.require("esri.tasks.query");
dojo.require("esri.dijit.Scalebar");
dojo.require("esri.graphic");
dojo.require("esri.symbol");

Outcomes