Exemple #1
0
        public static RadarBounds GetRadarBoundsForScreen(this MKMapView map)
        {
            RadarBounds bounds = map.GetRadarBounds();

            bounds.Width  = map.Frame.Size.Width;
            bounds.Height = map.Frame.Size.Height;
            return(bounds);
        }
Exemple #2
0
        public static RadarBounds GetRadarBoundsForScreen(this MKMapView map)
        {
            RadarBounds bounds = map.GetRadarBounds();

            var rect = map.ConvertRegion(map.Region, map.Superview);

            bounds.Width  = rect.Width * UIScreen.MainScreen.Scale;
            bounds.Height = rect.Height * UIScreen.MainScreen.Scale;

            return(bounds);
        }
Exemple #3
0
        public Task <byte []> GetRadarImageAsync(RadarBounds bounds)
        {
            try {
                var query = $"image.gif?maxlat={bounds.MaxLat}&maxlon={bounds.MaxLon}&minlat={bounds.MinLat}&minlon={bounds.MinLon}&width={bounds.Width}&height={bounds.Height}&rainsnow={1}&num={6}&delay={25}";

                var url = ApiKeys.WuApiKeyedQueryFmt.Fmt("animatedradar", query);

                System.Diagnostics.Debug.WriteLine(url);

                return(client.GetAsync <byte []> (url));
            } catch (WebServiceException webEx) {
                System.Diagnostics.Debug.WriteLine($"Exception processing Weather Underground request for Radar Image\n{webEx.Message}");
                throw;
            } catch (Exception ex) {
                System.Diagnostics.Debug.WriteLine($"Exception processing Weather Underground request for Radar Image\n{ex.Message}");
                throw;
            }
        }
Exemple #4
0
        public static RadarBounds GetRadarBounds(this MKMapView map)
        {
            CLLocationCoordinate2D center = map.CenterCoordinate;

            var topLeft     = MKMapPoint.FromCoordinate(new CLLocationCoordinate2D(center.Latitude + (map.Region.Span.LatitudeDelta / 2.0), center.Longitude - (map.Region.Span.LongitudeDelta / 2.0)));
            var bottomRight = MKMapPoint.FromCoordinate(new CLLocationCoordinate2D(center.Latitude - (map.Region.Span.LatitudeDelta / 2.0), center.Longitude + (map.Region.Span.LongitudeDelta / 2.0)));

            var bounds = new RadarBounds {
                MinLat = center.Latitude + (map.Region.Span.LatitudeDelta / 2.0),
                MaxLat = center.Latitude - (map.Region.Span.LatitudeDelta / 2.0),
                MinLon = center.Longitude - (map.Region.Span.LongitudeDelta / 2.0),
                MaxLon = center.Longitude + (map.Region.Span.LongitudeDelta / 2.0),

                Height = Math.Abs(topLeft.Y - bottomRight.Y),
                Width  = Math.Abs(topLeft.X - bottomRight.X)
            };

            return(bounds);
        }