Esempio n. 1
0
        public override void OnMoveToRegionRequest(MoveToRegionMessage m)
        {
            if (_nativeMap == null)
            {
                return;
            }

            var span    = m.Span;
            var animate = m.Animate;

            span = span.ClampLatitude(85, -85);
            var ne     = new LatLng(span.Center.Latitude + span.LatitudeDegrees / 2, span.Center.Longitude + span.LongitudeDegrees / 2);
            var sw     = new LatLng(span.Center.Latitude - span.LatitudeDegrees / 2, span.Center.Longitude - span.LongitudeDegrees / 2);
            var update = GCameraUpdateFactory.NewLatLngBounds(new LatLngBounds(sw, ne), 0);

            try
            {
                if (animate)
                {
                    _nativeMap.AnimateCamera(update);
                }
                else
                {
                    _nativeMap.MoveCamera(update);
                }
            }
            catch (IllegalStateException exc)
            {
                System.Diagnostics.Debug.WriteLine("MoveToRegion exception: " + exc);
            }
        }
        internal void MoveToRegion(MapSpan span, bool animate)
        {
            if (_nativeMap == null)
            {
                return;
            }

            span = span.ClampLatitude(85, -85);
            var ne     = new LatLng(span.Center.Latitude + span.LatitudeDegrees / 2, span.Center.Longitude + span.LongitudeDegrees / 2);
            var sw     = new LatLng(span.Center.Latitude - span.LatitudeDegrees / 2, span.Center.Longitude - span.LongitudeDegrees / 2);
            var update = GCameraUpdateFactory.NewLatLngBounds(new LatLngBounds(sw, ne), 0);

            try
            {
                if (animate)
                {
                    _nativeMap.AnimateCamera(update);
                }
                else
                {
                    _nativeMap.MoveCamera(update);
                }
            }
            catch (IllegalStateException exc)
            {
                System.Diagnostics.Debug.WriteLine("MoveToRegion exception: " + exc);
            }
        }