Exemple #1
0
        public void Run()
        {
            long  elapsed = SystemClock.UptimeMillis() - _start;
            float t       = _interpolator.GetInterpolation((float)elapsed
                                                           / (float)_duration);
            double lng = t * _toPosition.Longitude + (1 - t)
                         * _startPosition.Longitude;
            double lat = t * _toPosition.Latitude + (1 - t)
                         * _startPosition.Latitude;

            var endLatLng = new LatLng(lat, lng);

            if (NeedUpdateRotation())
            {
                var heading = SphericalUtil.computeHeading(_marker.Position, endLatLng);
                heading = heading + 180;
                //if (Options.HeadingConverter != null)
                //    heading = Options.HeadingConverter(heading);
                double mapHeading = 0;
                if (_gMap?.CameraPosition != null)
                {
                    mapHeading = -_gMap.CameraPosition.Bearing;
                }
                _marker.Rotation     = (float)heading + (float)mapHeading;
                _lastUpdatedLocation = endLatLng;
            }

            _marker.Position = endLatLng;

            if (t < 1.0)
            {
                // Post again 16ms later.
                _handler.PostDelayed(this, 16);
            }
            else
            {
                _endAction?.Invoke();
            }
            //else
            //{
            //    if (hideMarker)
            //    {
            //        marker.Visible = false;
            //    }
            //    else
            //    {
            //        marker.Visible = true;
            //    }
            //}
        }