Click here to Skip to main content
15,039,149 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:
XML
<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>
            <DataTemplate>
                <map:MapPolyline Stroke="Aqua" Opacity="0.85" StrokeThickness="6" />
            </DataTemplate>
        </map:MapItemsControl>-->
        <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.

C#
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
Posted
Updated 10-Nov-15 6:59am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900