private async void Init()
        {
            try {
                var start = new Position();

                start.Latitude  = driver.Lat;
                start.Longitude = driver.Lon;

                this.destination = await Ride2GoService.GetPosition(this.destinationName);

                var routeResult = await Ride2GoService.GetRoute(start, destination, this.riderPosition);

                var points = routeResult.Locations;

                this.MapView.AddOverlay(MKPolyline.FromCoordinates(points));
                var annotation = new BasicMapAnnotation(new CLLocationCoordinate2D(driver.Lat, driver.Lon), driver.Name);
                this.MapView.AddAnnotation(annotation);
                this.TimeLabel.Text = routeResult.Eta;

                this.timer     = new Timer();
                timer.Interval = 2500;
                timer.Start();
                timer.Elapsed += this.TimerTick;
            } catch (Exception e)
            {
                Application.PresentOKAlert("hallo", e.Message, this, () => { });
            }
        }
        private async void TimerHasTicked()
        {
            this.driver = await Ride2GoService.GetDriverUpdate(pollCount);

            var driverPosition = new Position()
            {
                Latitude = driver.Lat, Longitude = driver.Lon
            };

            var routeResult = await Ride2GoService.GetRoute(driverPosition, this.riderPosition, null);

            this.InvokeOnMainThread(
                () => {
                var annotation = new BasicMapAnnotation(new CLLocationCoordinate2D(driver.Lat, driver.Lon), driver.Name);
                this.MapView.RemoveAnnotations(this.MapView.Annotations);
                this.MapView.AddAnnotation(annotation);
                this.TimeLabel.Text = routeResult.Eta;
                pollCount++;
            });


            if (pollCount > 2)
            {
                this.timer.Elapsed -= TimerTick;
                Application.PresentOKAlert("Driver arrived", "Look for the blinking car",
                                           this,
                                           () => { });
                this.InvokeOnMainThread(() => { this.TimeLabel.Text = "arrived"; });
                Ride2GoService.MakeTheCarBlink();
            }
        }
Exemplo n.º 3
0
        private async void DrawInitialRoute()
        {
            this.destinationPosition = await Ride2GoService.GetPosition(destination);

            var routeResult = await Ride2GoService.GetRoute(this.driverPosition, destinationPosition, null);

            this.firstRoute = MKPolyline.FromCoordinates(routeResult.Locations);
            this.MapView.AddOverlay(this.firstRoute);
        }
Exemplo n.º 4
0
        private async void TimerHasTicked()
        {
            var driver = await Ride2GoService.GetDriverNearby();

            if (driver != null)
            {
                this.timer.Elapsed -= TimerTick;
                this.driver         = driver;
                Application.PresentOKAlert("Driver found", "You will drive with " + driver.Name, this, () => this.PerformSegue("DriverFoundSegue", this));
            }
        }
Exemplo n.º 5
0
        private async void TimerHasTicked()
        {
            var rider = await Ride2GoService.GetRiderNearby();

            if (rider != null)
            {
                this.timer.Elapsed -= TimerTick;
                Application.PresentOKAlert("Passenger found", "you are being rerouted",
                                           this,
                                           () => OverlayNewRoute(rider));
            }
        }
Exemplo n.º 6
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            Ride2GoService.RequestRide("Marcel", this.position.Latitude, this.position.Longitude, this.destination);

            this.DestinationLabel.Text = this.destination;
            this.timer     = new Timer();
            timer.Interval = 3000;
            timer.Start();
            timer.Elapsed += this.TimerTick;
            this.LoadingIndicator.StartAnimating();
        }
Exemplo n.º 7
0
        private async void OverlayNewRoute(Rider rider)
        {
            this.MapView.RemoveOverlay(this.firstRoute);

            //rider.Position
            var pickupPoint = new Position();

            pickupPoint.Latitude  = rider.Lat;
            pickupPoint.Longitude = rider.Lon;

            var routeResult = await Ride2GoService.GetRoute(this.driverPosition, this.destinationPosition, pickupPoint);

            this.MapView.AddOverlay(MKPolyline.FromCoordinates(routeResult.Locations));
            var annotation = new BasicMapAnnotation(new CLLocationCoordinate2D(rider.Lat, rider.Lon), rider.Name);

            this.MapView.AddAnnotation(annotation);
        }