0
votes

I am not able to remove waypoints from bing map in c# (WPF), i had used waypoint remove, clear, removeat but still not removed.....

  1. How to remove waypoints from bing map in c#
  2. also provide code to delete the path between waypoints

Source and destination are Location(latitude,longitude)

startWaypoint = new Bing.Maps.Directions.Waypoint(Source);
endWaypoint = new Bing.Maps.Directions.Waypoint(Destination);

waypoints = new Bing.Maps.Directions.WaypointCollection();
waypoints.Add(startWaypoint);
waypoints.Add(endWaypoint);

//Start = waypoints.IndexOf(startWaypoint);
//End = waypoints.IndexOf(endWaypoint);

directionsManager = GuideMap.DirectionsManager;
directionsManager.Waypoints = waypoints;

// Calculate route directions
Bing.Maps.Directions.RouteResponse response = await directionsManager.CalculateDirectionsAsync();

route = response.Routes[0];
// Display the route on the map
directionsManager.ShowRoutePath(response.Routes[0]);
3
I still Did not get any solution for my problem, So if anybody have any solution, are most welcome.Sachin

3 Answers

0
votes

I think this would work

    directionsManager.Waypoints.Remove(startWaypoint);

I'm not sure haven't tested it.

To clear the route

    directionsManager.ClearActiveRoute();
0
votes

I got the Code for the same:-

//To clear the path or route & //To clear or delete the Waypints of a path or route.

        GuideMap.DirectionsManager.HideRoutePath(GuideMap.DirectionsManager.ActiveRoute);
        GuideMap.DirectionsManager.ClearActiveRoute();
        MapLayer directionsLayer = VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(GuideMap, 0), 0), 0) as MapLayer;
        directionsLayer.Children.Clear();
0
votes

Long time to get an answer but I'm researching the same issue on clearing a route

replace:

directionsManager.ShowRoutePath(response.Routes[0]);

with:

directionsManager.ActiveRoute(response.Routes[0]);

then the:

directionsManager.ClearActiveRoute();