Graphic Moves in Graphic Layer

605
1
02-03-2011 01:06 PM
JaclynGorman
New Contributor
I have 2 graphic layers in my code.  They are both created by drawing on the map.  Basically there are 2 drawing toolbars.  I wanted users to be able to clear one graphics layer or the other independently.  The code works, but the graphics in the layer move when I pan around the map.  If I take away the graphics layers, the graphics do not move when I pan.  Are there any ideas on what would cause this?  Thanks

Jaclyn
0 Kudos
1 Reply
JaclynGorman
New Contributor
I think I finally figured this out.  Apparently with the graphics layers,unlike most layers, you have to wait for the map to load before adding a new GraphicsLayer.

For example:
you can't just have

var NewGraphics
NewGraphics = new esri.layers.GraphicsLayer({});
map.addLayer(NewGraphics);

Instead you have to have

NewGraphics = new esri.layers.GraphicsLayer({});
  dojo.connect(map, "onLoad", function() {
     map.addLayer(NewGraphics);
  });
0 Kudos