Esempio 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;
                }
            }
        }
Esempio 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));
            }
        }