cadrin

Why my graphics are not added to the map?

Discussion created by cadrin on Dec 4, 2012
Latest reply on Dec 7, 2012 by cadrin
Hi all,

I'm following this example (but programmatically) http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/find_map_datagrid.html

and I don't know why my graphic are not showing up...

Thank's for your help.

//display the location results on the map 
function showResultsLocator(results) 
{
    map = getMap();
    //find results return an array of findResult.
    console.dir(map); // my map object is fully working here
    map.graphics.clear();
    var dataForGrid = [];
    //Build an array of attribute information and add each found graphic to the map
    var cpt = 0;
    //console.log(results);
    
    
    dojo.forEach(results, function(result) 
    {
     cpt++;
     var graphic = result.feature;
              
     //console.log(graphic.attributes.NAD83+","+ graphic.attributes.CIVIQUE+","+ graphic.attributes.VOIE);
  dataForGrid.push([result.layerName,graphic.attributes.NAD83, graphic.attributes.CIVIQUE, graphic.attributes.VOIE]);
  
        var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.5]));
        graphic.setSymbol(symbol);
  map.graphics.add(graphic);  // the graphics are not added to the map. Why?
 });
 //console.log(dataForGrid);
 generateTableSearch(dataForGrid);
 //console.log("cpt search = "+cpt);
 $('#nb_res_search').empty();
 $('#nb_res_search').text('Nb. résultat(s): '+cpt);
}

Outcomes