Geocoding.net icon indicating copy to clipboard operation
Geocoding.net copied to clipboard

ReverseGeocodeAsync only returns a FormattedAddress string

Open jphellemons opened this issue 8 years ago • 2 comments

I am looking to extract only the city for a given lat/lng As seen in this XML: https://stackoverflow.com/a/3151512/169714 it would have an enumerable of address_component and a type locality which contains the city.

Would be a great addition imho.

jphellemons avatar Nov 26 '17 08:11 jphellemons

I think that the GeoCoding.Core.Address class could use some more properties. GoogleAddress has components and BingAddress several other properties. What are your thoughts on this?

jphellemons avatar Nov 26 '17 08:11 jphellemons

Fixed it by not using the address class but provider specific:

Geocoding.Google.GoogleAddress gAdres = (Geocoding.Google.GoogleAddress)geoGoogle.ReverseGeocodeAsync

and

Geocoding.Microsoft.BingAddress adres = (Geocoding.Microsoft.BingAddress)geoBing.ReverseGeocodeAsync

and for google

string city = gAdres.Components.FirstOrDefault(g => g.Types.Equals("locality")).LongName;

and for microsoft/bing

string city = adres.Locality;

jphellemons avatar Nov 26 '17 14:11 jphellemons