public string GetMapUri(float latitude, float longitude, int zoom, int scale, int width, int height, GoogleMapType mapType, GoogleImageFormat format, IList <TrackCoordinate> trackCoordinates)
        {
            var requestUri = string.Empty;

            for (int i = _resolutionModifierStep; i <= _maxResolutionModifierStep; i++)
            {
                if (i > _resolutionModifierStep)
                {
                    _logger.LogTrace($"Attempting to build Track Map requestUri at resolution of {i}");
                }
                string pathParameter = BuildMapPath(trackCoordinates, i);

                requestUri = string.Format(
                    "https://maps.googleapis.com/maps/api/staticmap?center={0}&zoom={1}&size={2}&maptype={3}&format={4}{5}&key={6}",
                    $"{latitude},{longitude}",
                    zoom,
                    $"{width}x{height}",
                    GoogleMapHelper.GetGoogleMapTypeString(mapType),
                    GoogleMapHelper.GetGoogleFormatString(format),
                    pathParameter,
                    GoogleMapHelper.ApiKey);

                if (requestUri.Length < 8192)
                {
                    break;
                }
                else if (requestUri.Length > 8192 && i >= _maxResolutionModifierStep)
                {
                    throw new InvalidOperationException($"requestUri too long: {requestUri.Length}");
                }
            }

            return(requestUri);
        }
 public string GetMapUri(float latitude, float longitude, int zoom)
 {
     return(string.Format(
                "https://maps.googleapis.com/maps/api/staticmap?center={0}&zoom={1}&size={2}&maptype={3}&format={4}&key={5}",
                $"{latitude},{longitude}",
                zoom,
                "640x640",
                GoogleMapHelper.GetGoogleMapTypeString(GoogleMapType.Satellite),
                GoogleMapHelper.GetGoogleFormatString(GoogleImageFormat.PNG32),
                GoogleMapHelper.ApiKey));
 }
        public async Task <byte[]> GetMapAsync(float latitude, float longitude, int zoom, int scale, int width, int height, GoogleMapType mapType, GoogleImageFormat format, IList <TrackCoordinate> trackCoordinates)
        {
            byte[] bitmap = null;

            try
            {
                var requestUri = string.Empty;

                for (int i = _resolutionModifierStep; i <= _maxResolutionModifierStep; i++)
                {
                    if (i > _resolutionModifierStep)
                    {
                        _logger.LogTrace($"Attempting to build Track Map requestUri at resolution of {i}");
                    }
                    string pathParameter = BuildMapPath(trackCoordinates, i);

                    requestUri = string.Format(
                        "https://maps.googleapis.com/maps/api/staticmap?&scale=1center={0}&zoom={1}&size={2}&maptype={3}&format={4}&key={5}{6}",
                        $"{latitude},{longitude}",
                        zoom,
                        $"{width}x{height}",
                        GoogleMapHelper.GetGoogleMapTypeString(mapType),
                        GoogleMapHelper.GetGoogleFormatString(format),
                        GoogleMapHelper.ApiKey,
                        pathParameter);

                    if (requestUri.Length < 8192)
                    {
                        break;
                    }
                    else if (requestUri.Length > 8192 && i >= _maxResolutionModifierStep)
                    {
                        throw new InvalidOperationException($"requestUri too long: {requestUri.Length}");
                    }
                }
                _logger.LogTrace($"Google Maps requestUri: {requestUri}");

                using (WebClient wc = new WebClient())
                {
                    bitmap = await wc.DownloadDataTaskAsync(new Uri(requestUri));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Exception in GetMapAsync");
                throw;
            }

            return(bitmap);
        }