Hey guys,
I am already searching many hours for a solution to display a calculated route with multiple waypoints on a bing map within my WPF application.
For my WPF application I am using MVVM light. So I have my own "MapWindow.xaml" and a View Model called "MapVM.cs".
Within my map I have already the map control:
<Grid Grid.Row="0" Margin="10,10,10,229">
<map:Map CredentialsProvider="{StaticResource MyEducationCredentials}" Margin="0,10,0,0" Mode="{Binding MapViewModel.MapMode}" Center="{Binding MapViewModel.MapCenter}" ZoomLevel="{Binding MapViewModel.ZoomLevel}">
<map:MapItemsControl ItemsSource="{Binding MapViewModel.MapMarkers}"></map:MapItemsControl>
</map:Map>
</Grid>
My application can already display multiple pushins and now I want to display also routes with multiple waypoints.
Like in this
post, I calculated the route but I do not know how to display this route on the bing map.
Credentials cred = new Credentials();
cred.ApplicationId = ConfigurationManager.AppSettings["MyEducationCredentials"];
BingServices.RouteRequest a = new BingServices.RouteRequest();
a.Credentials = cred;
a.Options = new BingServices.RouteOptions();
a.Options.Mode = BingServices.TravelMode.Driving;
a.Options.Optimization = BingServices.RouteOptimization.MinimizeDistance;
a.Waypoints = new BingServices.Waypoint[pointsOfInterestPerDay.Count];
int counter = 0;
foreach (var item in pointsOfInterestPerDay)
{
BingServices.Location loca = new BingServices.Location();
loca.Latitude = item.Latitude;
loca.Longitude = item.Longitude;
a.Waypoints[counter] = new BingServices.Waypoint() { Location = loca, Description = "Test" };
++counter;
}
BingServices.RouteServiceClient rClient = new BingServices.RouteServiceClient("BasicHttpBinding_IRouteService");
BingServices.RouteResponse response = rClient.CalculateRoute(a);
So how can I display the route now to be MVVM conform?
Thank you very much for your help!
Regards
Michael