Example #1
0
        public void Rotate(double latitude,
                           double longitude,
                           Action callback)
        {
            //gán lại vòng quay
            var mRotateIndex = 0;

            // * tính góc quay giữa 2 điểm location
            var angle = GeoHelper.ComputeHeading(this.Position.Latitude, this.Position.Longitude, latitude, longitude);

            if (angle == 0)
            {
                callback();
                return;
            }

            //tính lại độ lệch góc
            var deltaAngle = GeoHelper.GetRotaion(this.Rotation, angle);

            var startRotaion = this.Rotation;

            Device.StartTimer(TimeSpan.FromMilliseconds(50), () =>
            {
                //góc quay tiếp theo
                var fractionAngle = GeoHelper.ComputeRotation(
                    mRotateIndex / 10,
                    startRotaion,
                    deltaAngle);
                mRotateIndex = mRotateIndex + 1;

                this.Rotation = (float)fractionAngle;

                if (mRotateIndex > 10)
                {
                    callback();
                    return(false);
                }

                return(true);
            });
        }