- Geocode one-line addresses.
- Determine timezone information for a given address.
- This package uses the Google Maps Web Services to geocode the address.
- You will require the Geocoding API enabled, and optionally the [Timezone API] if you wish to also use
Timezone()
. - Remember to set your
GOOGLE_MAPS_API_KEY
environment variable.
go get -u github.com/mattevans/abode
addr := "193 Rogers Ave, Brooklyn, New York"
address, err := abode.ExplodeWithContext(ctx, addr)
if err != nil {
return err
}
Returns...
abode.Address{
AddressLine1: "193 Rogers Avenue",
AddressLine2: "Brooklyn"
AddressCity: nil,
AddressState: "New York"
AddressCountry: "United States"
AddressZip: "11216"
AddressLat: 40.6706073,
AddressLng: -73.9530182,
FormattedAddress: "193 Rogers Ave, Brooklyn, NY 11216, USA",
}
addr := "193 Rogers Ave, Brooklyn, New York"
address, err := abode.Timezone(ctx, addr)
if err != nil {
return err
}
Returns...
abode.Location{
DstOffset: 0,
RawOffset: -17762,
TimeZoneId: "GMT-04:56:02",
TimeZoneName: "America/New_York"
}
Ensure your end results are used in conjunction with a Google Map to avoid violating the Google Maps API Terms of Service.