AnsweredAssumed Answered

Javascript label graphic points

Question asked by deleted-user-yA_w_FC9FKe5 on Sep 29, 2014
Latest reply on Sep 30, 2014 by sarahclark


I have successfully been able to query my results and put them in a table and show them as points on my map thanks to a lot of help from these forums.

 

Now what I would like to do is create another graphics layer that just has labeling for these points but I am struggling with this.  I've searched endlessly for a way to do this.  I've looked through the samples I've found something called a labellayer but I don't know how to apply that.  I would think I would be able to use something like what I did for the graphics below but instead of a symbol use text.  I created a StoresResultsLayer_Labels as you can see below.  I'm sure this is simple but it is not for me for some reason.  Any help is greatly appreciated.

 

//My layers loaded at the start of the application but blank

StoresResultsLayer = new GraphicsLayer();
StoresResultsLayer.id = 'StoresResults';  
map.addLayer(StoresResultsLayer,0);

 

StoresResultsLayer_Labels = new GraphicsLayer();
StoresResultsLayer_Labels.id = 'StoresResults_Labels';  
map.addLayer(StoresResultsLayer_Labels,0);

 

 

 

//Some of my code from my function

var symbol = new esri.symbol.SimpleMarkerSymbol({ 

"color": [255,255,0,255], 

"size": 11, 

"xoffset": 1, 

"yoffset": -2, 

"type": "esriSMS", 

"style": "esriSMSCircle", 

"outline": {   

"color": [0,0,0,255],   

"width": 3,   

"type": "esriSLS",   

"style": "esriSLSSolid"  }});


   var dataForGrid = [];
var temp = "";
    //remove all graphics on the maps graphics layer   
    StoresResultsLayer.clear();
     //Performance enhancer - assign featureSet array to a single variable.   
     var resultFeatures = featureSet.features;   
     //Loop through each feature returned   

        
     for (var i=0, il=resultFeatures.length; i<il; i++) {     
     //Get the current feature from the featureSet.     
     //Feature is a graphic     
     var graphic = resultFeatures[i];     
     resultFeatures[i].setSymbol(symbol);
    
    
  StoresResultsLayer.add(resultFeatures[i]);
  StoresResultsLayer.show();

Outcomes