/// <summary> /// Sets the route calculation data /// </summary> /// <param name="route">The PCL route</param> /// <param name="routeResult">The rourte api result</param> private void SetRouteData(TKRoute route, GmsRouteResult routeResult) { var latLngBounds = new LatLngBounds( new LatLng(routeResult.Bounds.SouthWest.Latitude, routeResult.Bounds.SouthWest.Longitude), new LatLng(routeResult.Bounds.NorthEast.Latitude, routeResult.Bounds.NorthEast.Longitude)); var apiSteps = routeResult.Legs.First().Steps; var steps = new TKRouteStep[apiSteps.Count()]; var routeFunctions = (IRouteFunctions)route; for (int i = 0; i < steps.Length; i++) { steps[i] = new TKRouteStep(); var stepFunctions = (IRouteStepFunctions)steps[i]; var apiStep = apiSteps.ElementAt(i); stepFunctions.SetDistance(apiStep.Distance.Value); stepFunctions.SetInstructions(apiStep.HtmlInstructions); } routeFunctions.SetSteps(steps); routeFunctions.SetDistance(routeResult.Legs.First().Distance.Value); routeFunctions.SetTravelTime(routeResult.Legs.First().Duration.Value); routeFunctions.SetBounds( MapSpan.FromCenterAndRadius( latLngBounds.Center.ToPosition(), Distance.FromKilometers( new Position(latLngBounds.Southwest.Latitude, latLngBounds.Southwest.Longitude) .DistanceTo( new Position(latLngBounds.Northeast.Latitude, latLngBounds.Northeast.Longitude))))); }
///<inheritdoc/> void IRouteFunctions.SetSteps(TKRouteStep[] steps) { this.Steps = steps; }
/// <summary> /// Sets the route data /// </summary> /// <param name="route">PCL route</param> /// <param name="nativeRoute">Native route</param> private void SetRouteData(TKRoute route, MKRoute nativeRoute) { var routeFunctions = (IRouteFunctions)route; var steps = new TKRouteStep[nativeRoute.Steps.Count()]; for (int i = 0; i < steps.Length; i++) { steps[i] = new TKRouteStep(); var stepFunction = (IRouteStepFunctions)steps[i]; var nativeStep = nativeRoute.Steps.ElementAt(i); stepFunction.SetInstructions(nativeStep.Instructions); stepFunction.SetDistance(nativeStep.Distance); } routeFunctions.SetSteps(steps); routeFunctions.SetDistance(nativeRoute.Distance); routeFunctions.SetTravelTime(nativeRoute.ExpectedTravelTime); routeFunctions.SetBounds( MapSpan.FromCenterAndRadius( new Position( nativeRoute.Polyline.BoundingMapRect.MidX, nativeRoute.Polyline.BoundingMapRect.MidY), Distance.FromKilometers( route.Source.DistanceTo(route.Destination)))); }