1
I’m trying to implement on top of a ready-made class that I was sent that uses Googleapi, but I can’t possibly add the reference to the project via Nuget. Do you know where I can download it? Follow 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’t add to the reference to my.
Thank you!
tried to grab the other project’s api and add the reference to this ?
– Rovann Linhalis
The guy traveled, sent me the class by email, then it gets hard kkk
– T. Borges