private static string GetRequestUrl(this IGeocodingQuery query)
        {
            var requestBuilder = new StringBuilder(query.BaseServiceUrl);

            requestBuilder = requestBuilder.AppendFormat("?key={0}", query.ApiKey);

            foreach (var param in query.Params)
            {
                requestBuilder = requestBuilder.AppendFormat("&{0}={1}", param.Key, param.Value);
            }

            return(requestBuilder.ToString());
        }
 public static async Task <string> GetResultAsync(this IGeocodingQuery query)
 {
     return(await GoogleMapGeocodingHttpClient.Instance.GetStringAsync(GetRequestUrl(query)));
 }
        public static async Task <GeocodingResultLite> GetGeocodingResultAsync(this IGeocodingQuery query)
        {
            var responseAsString = await query.GetResultAsync();

            return(JsonConvert.DeserializeObject <GeocodingResultLite>(responseAsString));
        }
示例#4
0
 public static IGeocodingQuery WithAddress(this IGeocodingQuery query, string address)
 {
     query.Params["address"] = address;
     return(query);
 }
示例#5
0
 public static IGeocodingQuery WithResultType(this IGeocodingQuery query, ResultType resultType)
 {
     query.Params["result_type"] = Enum.GetName(typeof(ResultType), resultType);
     return(query);
 }
示例#6
0
 public static IGeocodingQuery WithLocationType(this IGeocodingQuery query, LocationType locationType)
 {
     query.Params["location_type"] = Enum.GetName(typeof(LocationType), locationType);
     return(query);
 }
示例#7
0
 public static IGeocodingQuery WithCordinate(this IGeocodingQuery query, Location location)
 {
     query.Params["latlng"] = string.Format("{0},{1}", location.Latitude, location.Longitude);
     return(query);
 }