Clearing SketchGraphicLayer

387
1
03-29-2011 10:54 AM
EswariManickam
New Contributor II
I am currently trying to clear all the geometry drawn on the sketchGraphic Layer using the following code:

currentGraphicLayer.Geometry.Clear();
currentGraphicLayer.GeometryBag.Clear();

where currentGraphic layer is a sketchGraphicLayer to which I add my geometries;

However, not all geometries are cleared. Some are still seen on the map and when I draw the next geometry (polygon), it gets cleared. Is there something I am missing. Any help would be appreciated.

Thanks!
0 Kudos
1 Reply
MelindaFrost
Occasional Contributor
try also removing the graphic from the map, clearing geometry bag and add back to map

           
map.MapGraphicLayers.Remove(currentGraphicLayer);
            currentGraphicLayer.GeometryBag.Clear();
            
            map.MapGraphicLayers.Add(currentGraphicLayer);
0 Kudos