locked
Remove PolyLine from Bing Map RRS feed

  • Question

  • Hi Expert i am putting some Poly Lines on BingMap. i have to remove all the PolyLines from the map in a Button Click. The related pushpins are removing but the points and PolyLines are not removing. How to resolve this problem.

    Please suggest.

    Thank you.


    saroj

    Tuesday, September 11, 2012 5:21 AM

Answers

  • if u r adding all polylines to a MapLayer(i.e. child layer to MainMap) then just below code is enough to remove all polylines

    e.g. MainMap.children.remove(MapLayer);

    Thanks

    • Proposed as answer by prakash_light Wednesday, September 12, 2012 9:36 AM
    • Marked as answer by Ricky_Brundritt Friday, September 14, 2012 12:44 PM
    Wednesday, September 12, 2012 5:09 AM
  • You can also use the MapLayer.Children.Clear method. This will remove both the polylines and the points.

    http://rbrundritt.wordpress.com

    • Proposed as answer by prakash_light Wednesday, September 12, 2012 9:36 AM
    • Marked as answer by Ricky_Brundritt Friday, September 14, 2012 12:44 PM
    Wednesday, September 12, 2012 9:12 AM

All replies

  • Which map control are you using and how are you trying to remove your polylines?

    http://rbrundritt.wordpress.com

    Tuesday, September 11, 2012 7:31 AM
  • Hi Richard I want to remove the Polyline on Selection Basis. So i am taking one Dictionary of type <string PolyLine> where i am storing key and PolyLine object. i am pasting the code below.

                                                  

     foreach (var poly in _removeSelectedPolyLine.Keys)
                {
                    if (poly == key)// key is a parameter of my Method
                    {

                        myRouteLayer.Children.Remove(_removeSelectedPolyLine[poly]);//myRouteLayer is MapLayer object


                    }

                }

    **********************Clearing PolyLines in Another way**********

    I am doing it in another way. In this case The Polylines are removing but the Points are not removing. what should i do.

    foreach (MapLayer ml in x_Map.Children.OfType<MapLayer>())
                {
                    foreach (MapPolyline pl in ml.Children.OfType<MapPolyline>())
                    {
                        ml.Children.Remove(pl);
                    }
                }


    Please suggest what i am doing wrong.

    Thank you.


    saroj


    Tuesday, September 11, 2012 8:40 AM
  • if u r adding all polylines to a MapLayer(i.e. child layer to MainMap) then just below code is enough to remove all polylines

    e.g. MainMap.children.remove(MapLayer);

    Thanks

    • Proposed as answer by prakash_light Wednesday, September 12, 2012 9:36 AM
    • Marked as answer by Ricky_Brundritt Friday, September 14, 2012 12:44 PM
    Wednesday, September 12, 2012 5:09 AM
  • You can also use the MapLayer.Children.Clear method. This will remove both the polylines and the points.

    http://rbrundritt.wordpress.com

    • Proposed as answer by prakash_light Wednesday, September 12, 2012 9:36 AM
    • Marked as answer by Ricky_Brundritt Friday, September 14, 2012 12:44 PM
    Wednesday, September 12, 2012 9:12 AM