I'm trying to implement over a ready-made class that sent me using GoogleAPI, but I can not in any way add the reference to the project via NuGet. Do you know where I can download it? Here is the code:
using System.Collections.Generic;
using System.IO;
using System.Net;
using GoogleAPI.Maps.Model; // Esta daqui
using GoogleAPI.Maps.Model.Geocoding; // Esta daqui também
using Newtonsoft.Json;
namespace CepApp
{
public class AddressUtil
{
public class Location
{
public double lat { get; set; }
public double lng { get; set; }
}
public class Geometry
{
public Bounds bounds { get; set; }
public Location location { get; set; }
public string location_type { get; set; }
public Viewport viewport { get; set; }
}
public class Result
{
public List<AddressComponent> address_components { get; set; }
public string formatted_address { get; set; }
public Geometry geometry { get; set; }
public string place_id { get; set; }
public List<string> types { get; set; }
}
public class RootObject
{
public List<Result> results { get; set; }
public string status { get; set; }
}
public static RootObject GetLatLongByAddress(string address)
{
var root = new RootObject();
var url =
string.Format(
"http://maps.googleapis.com/maps/api/geocode/json?address={0}&sensor=true_or_false", address);
var req = (HttpWebRequest)WebRequest.Create(url);
var res = (HttpWebResponse)req.GetResponse();
using (var streamreader = new StreamReader(res.GetResponseStream()))
{
var result = streamreader.ReadToEnd();
if (!string.IsNullOrWhiteSpace(result))
{
root = JsonConvert.DeserializeObject<RootObject>(result);
}
}
return root;
}
}
}
Reinforcing: The class was already implemented in another project, but I can not add the reference to mine.
Thank you!