Inheritance: BaseCustomAnnotation
        void UpdateCarAnnotationPosition(CLLocationCoordinate2D coordinate)
        {
            if (currentLocationAnnotation != null)
            {
                tripMapView.RemoveAnnotation(currentLocationAnnotation);
            }

            var color = CurrentTripViewModel != null && CurrentTripViewModel.IsRecording ? UIColor.Red : UIColor.Blue;

            currentLocationAnnotation = new CarAnnotation(coordinate, color);

            tripMapView.AddAnnotation(currentLocationAnnotation);
            tripMapView.Camera.CenterCoordinate = coordinate;
        }
Esempio n. 2
0
        void UpdateCarAnnotationPosition(CLLocationCoordinate2D coordinate)
        {
            if (currentLocationAnnotation != null)
                tripMapView.RemoveAnnotation(currentLocationAnnotation);

            var color = CurrentTripViewModel != null && CurrentTripViewModel.IsRecording ? UIColor.Red : UIColor.Blue;
            currentLocationAnnotation = new CarAnnotation(coordinate, color);

            tripMapView.AddAnnotation(currentLocationAnnotation);
            tripMapView.Camera.CenterCoordinate = coordinate;
        }
Esempio n. 3
0
        async Task ConfigurePastTripUserInterface()
        {
            NavigationItem.Title = PastTripsDetailViewModel.Title;
			sliderView.Hidden = false;
			tripSlider.Hidden = false;

			wayPointA.Layer.CornerRadius = wayPointA.Frame.Width / 2;
			wayPointA.Layer.BorderWidth = 2;
			wayPointA.Layer.BorderColor = UIColor.White.CGColor;

			wayPointB.Layer.CornerRadius = wayPointB.Frame.Width / 2;
			wayPointB.Layer.BorderWidth = 2;
			wayPointB.Layer.BorderColor = UIColor.White.CGColor;
            
            var success = await PastTripsDetailViewModel.ExecuteLoadTripCommandAsync(PastTripsDetailViewModel.Trip.Id);
            
            if(!success)
            {
                NavigationController.PopViewController(true);
                return;
            }
            // Setup map
            mapDelegate = new TripMapViewDelegate(false);
            tripMapView.Delegate = mapDelegate;
            tripMapView.ShowsUserLocation = false;

            if (PastTripsDetailViewModel.Trip == null || PastTripsDetailViewModel.Trip.Points == null || PastTripsDetailViewModel.Trip.Points.Count == 0)
                return;

            var coordinateCount = PastTripsDetailViewModel.Trip.Points.Count;
            // Draw endpoints
            var startEndpoint = new WaypointAnnotation(PastTripsDetailViewModel.Trip.Points[0].ToCoordinate(), "A");
            tripMapView.AddAnnotation(startEndpoint);

            var endEndpoint =
                new WaypointAnnotation(PastTripsDetailViewModel.Trip.Points[coordinateCount - 1].ToCoordinate(), "B");
            tripMapView.AddAnnotation(endEndpoint);

            // Draw route
            tripMapView.DrawRoute(PastTripsDetailViewModel.Trip.Points.ToCoordinateArray());

            // Draw car
            var carCoordinate = PastTripsDetailViewModel.Trip.Points[0];
            currentLocationAnnotation = new CarAnnotation(carCoordinate.ToCoordinate(), UIColor.Blue);
            tripMapView.AddAnnotation(currentLocationAnnotation);

            // Configure slider area
            ConfigureSlider();
            ConfigureWayPointButtons();
            ConfigurePoiAnnotations();
            recordButton.Hidden = true;

            tripMapView.SetVisibleMapRect(
                MKPolyline.FromCoordinates(PastTripsDetailViewModel.Trip.Points.ToCoordinateArray()).BoundingMapRect,
                new UIEdgeInsets(25, 25, 25, 25), false);

            tripMapView.CenterCoordinate = carCoordinate.ToCoordinate();
            UpdateTripStatistics(carCoordinate);
            NSNotificationCenter.DefaultCenter.AddObserver(new NSString("RefreshTripUnits"), HandleTripUnitsChanged);
        }
        async Task ConfigurePastTripUserInterface()
        {
            NavigationItem.Title = PastTripsDetailViewModel.Title;
            sliderView.Hidden    = false;
            tripSlider.Hidden    = false;

            wayPointA.Layer.CornerRadius = wayPointA.Frame.Width / 2;
            wayPointA.Layer.BorderWidth  = 2;
            wayPointA.Layer.BorderColor  = UIColor.White.CGColor;

            wayPointB.Layer.CornerRadius = wayPointB.Frame.Width / 2;
            wayPointB.Layer.BorderWidth  = 2;
            wayPointB.Layer.BorderColor  = UIColor.White.CGColor;

            var success = await PastTripsDetailViewModel.ExecuteLoadTripCommandAsync(PastTripsDetailViewModel.Trip.Id);

            if (!success)
            {
                NavigationController.PopViewController(true);
                return;
            }
            // Setup map
            mapDelegate                   = new TripMapViewDelegate(false);
            tripMapView.Delegate          = mapDelegate;
            tripMapView.ShowsUserLocation = false;

            if (PastTripsDetailViewModel.Trip == null || PastTripsDetailViewModel.Trip.Points == null || PastTripsDetailViewModel.Trip.Points.Count == 0)
            {
                return;
            }

            var coordinateCount = PastTripsDetailViewModel.Trip.Points.Count;
            // Draw endpoints
            var startEndpoint = new WaypointAnnotation(PastTripsDetailViewModel.Trip.Points[0].ToCoordinate(), "A");

            tripMapView.AddAnnotation(startEndpoint);

            var endEndpoint =
                new WaypointAnnotation(PastTripsDetailViewModel.Trip.Points[coordinateCount - 1].ToCoordinate(), "B");

            tripMapView.AddAnnotation(endEndpoint);

            // Draw route
            tripMapView.DrawRoute(PastTripsDetailViewModel.Trip.Points.ToCoordinateArray());

            // Draw car
            var carCoordinate = PastTripsDetailViewModel.Trip.Points[0];

            currentLocationAnnotation = new CarAnnotation(carCoordinate.ToCoordinate(), UIColor.Blue);
            tripMapView.AddAnnotation(currentLocationAnnotation);

            // Configure slider area
            ConfigureSlider();
            ConfigureWayPointButtons();
            ConfigurePoiAnnotations();
            recordButton.Hidden = true;

            tripMapView.SetVisibleMapRect(
                MKPolyline.FromCoordinates(PastTripsDetailViewModel.Trip.Points.ToCoordinateArray()).BoundingMapRect,
                new UIEdgeInsets(25, 25, 25, 25), false);

            tripMapView.CenterCoordinate = carCoordinate.ToCoordinate();
            UpdateTripStatistics(carCoordinate);
            NSNotificationCenter.DefaultCenter.AddObserver(new NSString("RefreshTripUnits"), HandleTripUnitsChanged);
        }