Exemplo n.º 1
0
        void timer_Tick(object sender, object e)
        {
#if WINDOWS_PHONE_APP
            Windows.Devices.Geolocation.Geopoint topLeft = null;

            try
            {
                this.MapControl.GetLocationFromOffset(new Windows.Foundation.Point(0, 0), out topLeft);
            }
            catch
            {
                var topOfMap = new Windows.Devices.Geolocation.Geopoint(new Windows.Devices.Geolocation.BasicGeoposition()
                {
                    Latitude  = 85,
                    Longitude = 0
                });

                Windows.Foundation.Point topPoint;
                this.MapControl.GetOffsetFromLocation(topOfMap, out topPoint);
                this.MapControl.GetLocationFromOffset(new Windows.Foundation.Point(0, topPoint.Y), out topLeft);
            }

            Windows.Devices.Geolocation.Geopoint bottomRight = null;
            try
            {
                this.MapControl.GetLocationFromOffset(new Windows.Foundation.Point(this.MapControl.ActualWidth, this.MapControl.ActualHeight), out bottomRight);
            }
            catch
            {
                var bottomOfMap = new Windows.Devices.Geolocation.Geopoint(new Windows.Devices.Geolocation.BasicGeoposition()
                {
                    Latitude  = -85,
                    Longitude = 0
                });

                Windows.Foundation.Point bottomPoint;
                this.MapControl.GetOffsetFromLocation(bottomOfMap, out bottomPoint);
                this.MapControl.GetLocationFromOffset(new Windows.Foundation.Point(0, bottomPoint.Y), out bottomRight);
            }

            if (topLeft != null && bottomRight != null)
            {
                var bounds = new Windows.Devices.Geolocation.GeoboundingBox(topLeft.Position, bottomRight.Position);
                _mapBounds = new Envelope(bounds.SoutheastCorner.Latitude, bounds.NorthwestCorner.Longitude, bounds.NorthwestCorner.Latitude, bounds.SoutheastCorner.Longitude);
            }
#else
            var bounds = this.MapControl.Bounds;
            _mapBounds = new Envelope(bounds.South, bounds.West, bounds.North, bounds.East);
#endif
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="GeoboundingBox"/> class, a
 /// Wpf-enabled wrapper for <see cref="Windows.Devices.Geolocation.GeoboundingBox"/>
 /// </summary>
 public GeoboundingBox(Windows.Devices.Geolocation.GeoboundingBox instance)
 {
     this.UwpInstance = instance;
 }