Removing buffering circle graphics in a WP7

763
1
01-09-2014 09:37 AM
Labels (1)
Kai_LunGoh
New Contributor
I have tried a lot of method but just can't remove the graphics of the circle drawn. Can someone help me with this ?

GraphicsLayer graphicsLayerHeat = map.Layers["Layer5_buffer"] as GraphicsLayer;


                foreach (var graphic in buffersList)
                {

                    //graphicsLayer.Graphics.Remove(graphic);
                    graphicsLayerHeat.Graphics.Remove(graphic);

                }


The above code is used for drawing a circle, I can't remove the graphics that is drawn on this layer. Help pls.

I have tried this but it wont work.           
 graphicsLayer = map.Layers["Layer5_buffer"] as GraphicsLayer;
            graphicsLayer.ClearGraphics();


The code to draw the buffer is here:

public void drawBuffer(double radius, int pointCount, MapPoint currentPoint, GraphicsLayer gl)
        {
            //bufferLayer.removeAll();
            MapPoint point = currentPoint;
            ESRI.ArcGIS.Client.Geometry.Polyline pl = new ESRI.ArcGIS.Client.Geometry.Polyline();
            ESRI.ArcGIS.Client.Geometry.Polygon polygon = new ESRI.ArcGIS.Client.Geometry.Polygon();
            ESRI.ArcGIS.Client.Geometry.PointCollection routePoint = new ESRI.ArcGIS.Client.Geometry.PointCollection();
            for (int i = 1; i <= pointCount; i++)
            {
                double x;
                double y;
                x = (point.X + radius * Math.Cos(2 * Math.PI / pointCount * i));
                y = (point.Y + radius * Math.Sin(2 * Math.PI / pointCount * i));
                routePoint.Add(new MapPoint(x, y));
            }
            routePoint.Add(routePoint[0]);
            polygon.Rings.Add(routePoint);
            GraphicsLayer mygraphicslayer = gl;
            //mygraphicslayer.ClearGraphics();
            Graphic graphic = new Graphic()
            {
                Geometry = polygon,
                Symbol = Heat

            };
            buffersList.Add(graphic);
            mygraphicslayer.Graphics.Add(graphic);
        }
0 Kudos
1 Reply
BKuiper
Occasional Contributor III
From your code it is not clear that "Layer5_buffer" is the actual graphics layer to which the graphics are being added.

Make sure that the GraphicsLayer ID to which the graphics are added matched the string in the following line

GraphicsLayer graphicsLayerHeat = map.Layers["Layer5_buffer"] as GraphicsLayer;
0 Kudos