chadly / Geocoding.net

C# GeoCoding / Address Validation API
MIT License
443 stars 155 forks source link

Can't get GoogleGeoLoc to work #144

Closed ZARk-be closed 3 years ago

ZARk-be commented 3 years ago

Hello,

I copy-pasted the example, but removed the API_KEY as google allows a couple of hits without API. IGeocoder geocoder = new GoogleGeocoder(); IEnumerable<Address> addresses = await geocoder.GeocodeAsync("1600 pennsylvania ave washington dc"); Console.WriteLine("Formatted: " + addresses.First().FormattedAddress); //Formatted: 1600 Pennsylvania Ave SE, Washington, DC 20003, USA Console.WriteLine("Coordinates: " + addresses.First().Coordinates.Latitude + ", " + addresses.First().Coordinates.Longitude); //Coordinates: 38.8791981, -76.9818437

I'm getting an Exception thrown :

XmlException: 'sans-serif' is an unexpected token. The expected token is '"' or '''. Line 1, position 253.

This exception was originally thrown at this call stack: System.Xml.XmlTextReaderImpl.Throw(System.Exception) System.Xml.XmlTextReaderImpl.Throw(string, string[]) System.Xml.XmlTextReaderImpl.ThrowUnexpectedToken(string, string) System.Xml.XmlTextReaderImpl.ParseAttributes() System.Xml.XmlTextReaderImpl.ParseElement() System.Xml.XmlTextReaderImpl.ParseElementContent() System.Xml.XmlTextReaderImpl.Read() System.Xml.XPath.XPathDocument.LoadFromReader(System.Xml.XmlReader, System.Xml.XmlSpace) System.Xml.XPath.XPathDocument.XPathDocument(System.IO.Stream) Geocoding.Google.GoogleGeocoder.LoadXmlResponse(System.Net.Http.HttpResponseMessage) ... [Call Stack Truncated]

ZARk-be commented 3 years ago

OK. fixed it.

You NEED an API key