The
RouteInfo
model holds the route information, including the coordinates of the locations that make up that route.
public class RouteInfo { public Route Route { get; private set; } public string RoutePath { get { if (Route != null) { return String.Join(",", Route.RoutePath.Line.Coordinates.Select(c => String.Join(" ", c))); } return ""; } } public string Pins { get; private set; } public RouteInfo(Resource resource) { Route = resource as Route; GeneratePins(); } }
As specified in JsonDataContracts,
we introduced in the previous chapter, we extract the route's locations from the Route.RoutePath.Line.Coordinates
object graph.
We also need to show pushpins at the beginning of each route leg, and at the destination:
private void GeneratePins() { var pins = new List<string>(); for (var i = 0; i < Route.RouteLegs.Length; i++) ...