AnsweredAssumed Answered

What happens when you remove a graphic?

Question asked by TimSparq on Jun 26, 2013
Latest reply on Jun 27, 2013 by TimSparq
I'm trying to manage labels for some graphics that I have added to a map such that the labels maintain their offset from the points they are drawn against as you zoom in and out. The labels are being drawn as TextSymbols on the graphics layer.

My idea is to remove and redraw the labels from the graphics layer on the map "onZoomEnd" event. However I'm getting seemingly inconsistent results from my function when removing the graphics.

I have created the below test to confirm... It seems to me that the conditional inside the 2nd for loop in that function should never pass as all the graphics with the attribute type == "label" should have been removed in the first loop, however the conditional in the 2nd loop does in fact execute.

What am I missing? Is there some kind of default onGraphicRemove event on the graphics layer that will cause a break in that first loop?

edit: This is the function attached to my map onZoomEnd event

 function drawLabels() {          for (var i = 0; i <; i++) {         var g =[i];         if (g.attributes != null && g.attributes.type == "label") {             alert("Removing once " + g.attributes.crewName);   ;         }     }          for (var i = 0; i <; i++) {         var g =[i];         if (g.attributes != null && g.attributes.type == "label") {             alert("Removing twice " + g.attributes.crewName);   ;         }     }          }