public async Task LoadRoute() { int positionIndex = 1; var googleDirection = await googleMapsApi.GetDirections("18.48849", "-69.971506", "18.5525209", "-69.4376482"); if (googleDirection.Routes != null && googleDirection.Routes.Count > 0) { var positions = Enumerable.ToList(PolylineHelper.Decode(googleDirection.Routes.First().OverviewPolyline.Points)); CalculateRouteCommand.Execute(positions); //Location tracking simulation Device.StartTimer(TimeSpan.FromSeconds(1), () => { if (positions.Count > positionIndex) { UpdatePositionCommand.Execute(positions[positionIndex]); positionIndex++; return(true); } else { return(false); } }); } else { await Application.Current.MainPage.DisplayAlert("No route", "No route found", "Ok"); } }
public async Task LoadRoute() { //var positionIndex = 1; var googleDirection = await googleMapsApi.GetDirections("18.5486875", "-70.2786714", "18.5525209", "-69.4376482"); if (googleDirection.Routes != null && googleDirection.Routes.Count > 0) { var positions = (Enumerable.ToList(PolylineHelper.Decode(googleDirection.Routes.First().OverviewPolyline.Points))); CalculateRouteCommand.Execute(positions); //Location tracking simulation //Device.StartTimer(TimeSpan.FromSeconds(1), () => //{ // if (positions.Count > positionIndex) // { // UpdatePositionCommand.Execute(positions[positionIndex]); // positionIndex++; // return true; // } // else // { // return false; // } //}); } }