Exemplo n.º 1
0
        public void PositionChanged(object sender, Plugin.Geolocator.Abstractions.PositionEventArgs arg)
        {
            if ((LocFlag == LocationFlag.Start || LocFlag == LocationFlag.InBackground) &&
                (RouteCoordinates.Count == 0 || arg.Position.Timestamp.Ticks != RouteCoordinates.Last().Timestamp.Ticks))    //first element can be null, so dont use it
            {
                RouteCoordinates.Add(new Plugin.Geolocator.Abstractions.Position(arg.Position));
                LastCoordinates.Add(new Plugin.Geolocator.Abstractions.Position(arg.Position));
                DrawPoint = new Plugin.Geolocator.Abstractions.Position(arg.Position);


                switch (Device.RuntimePlatform)
                {
                case Device.iOS:
                case Device.Android:
                    if (VisibleRegion != null)
                    {
                        this.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(arg.Position.Latitude, arg.Position.Longitude), VisibleRegion.Radius));
                    }
                    break;

                case Device.UWP:
                    //Implementation in native map

                    break;
                }
            }
        }
Exemplo n.º 2
0
        public void PositionChanged(object sender, PositionEventArgs arg)
        {
            var conventer = new WorkoutConventer();

            //start
            if (RouteCoordinates.Count == 0)
            {
                //WorkoutData.NumberOfPoint++;
                WorkoutData.StartTime = new DateTime(DateTime.Now.Ticks); //new DateTime(arg.Position.Timestamp.LocalDateTime.Ticks);
                startWorkout          = new DateTime(DateTime.Now.Ticks);
                UpdateWorkFieldAndObj(null, arg.Position);
                RouteCoordinates.Add(new Plugin.Geolocator.Abstractions.Position(arg.Position));
            }
            else if (startWorkout.Ticks == 0)
            {       //after pause, new value
                if (arg.Position.Timestamp.Ticks != RouteCoordinates.Last().Timestamp.Ticks)
                {
                    startWorkout = new DateTime(DateTime.Now.Ticks);
                    //WorkoutData.NumberOfPoint++;
                    //UpdateWorkFieldAndObj(RouteCoordinates.Last(), arg.Position);
                    UpdateWorkFieldAndObj(null, arg.Position);
                    RouteCoordinates.Add(new Plugin.Geolocator.Abstractions.Position(arg.Position));
                }
                else
                {    //after pause, if value is same
                    startWorkout = new DateTime(DateTime.Now.Ticks);
                }    //new value
            }
            else if (arg.Position.Timestamp.Ticks != RouteCoordinates.Last().Timestamp.Ticks)
            {
                NumberOfPoint++;
                UpdateWorkFieldAndObj(RouteCoordinates.Last(), arg.Position);
                RouteCoordinates.Add(new Plugin.Geolocator.Abstractions.Position(arg.Position));
            }
        }
Exemplo n.º 3
0
 public void LoadRoutes(List <Step> steps)
 {
     foreach (Step step in steps)
     {
         RouteCoordinates.Add(new Position(step.start_location.lat, step.start_location.lng));
         RouteCoordinates.Add(new Position(step.end_location.lat, step.end_location.lng));
         RoutesListUpdated?.Invoke(this, EventArgs.Empty);
     }
 }
Exemplo n.º 4
0
        public async Task StopListeningLocation(bool stopGeolocator, bool ifDataReset)
        {
            LocFlag = LocationFlag.Stop;

            LastPFlag = new Plugin.Geolocator.Abstractions.Position();

            if (ifDataReset == true)
            {
                platformRoad = new object();//is delete

                RouteCoordinates.Clear();
                LastCoordinates.Clear();
                DrawPoint = null;
                LastPFlag = null;
            }

            AppGeolocator.Current.PositionChanged -= PositionChanged;
            AppGeolocator.Current.PositionError   -= PositionError;

            await AppGeolocator.StopListeningAsync(MyGeoFlag, stopGeolocator);
        }
Exemplo n.º 5
0
        public async Task StopListeningLocation(bool stopGeolocator, bool ifDataReset)
        {
            AppGeolocator.Current.PositionChanged -= PositionChanged;
            AppGeolocator.Current.PositionError   -= PositionError;

            await AppGeolocator.StopListeningAsync(MyGeoFlag, stopGeolocator);


            if (ifDataReset == true)
            {
                RouteCoordinates.Clear();
                WorkoutData.Reset();
                NewWorkoutPoint = null;

                NumberOfPoint = 0;
                lastInterval  = new DateTime(0);
                startWorkout  = new DateTime(0);

                ResetCounter();
            }
        }