From 48ce60d00a4833d5bf6b554dc496ba126cfe20ff Mon Sep 17 00:00:00 2001 From: Tom Clifford Date: Wed, 14 Feb 2024 15:38:21 -0800 Subject: [PATCH] feat! Added Address Descriptors to Geocoding response. Refactored Geocoding response to allow fields outside the geocoding result to be exposed through the client. --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index 98cced0..8cd23eb 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,37 @@ func main() { } ``` +Sample usage of the Geocoding API with an API key to get an [Address Descriptor](https://mapsplatform.google.com/demos/address-descriptors/): + +```go +package main + +import ( + "context" + "log" + + "github.com/kr/pretty" + "googlemaps.github.io/maps" +) + +func main() { + c, err := maps.NewClient(maps.WithAPIKey("Insert-API-Key-Here")) + if err != nil { + log.Fatalf("fatal error: %s", err) + } + r := &maps.GeocodingRequest{ + LatLng: &LatLng{Lat: 40.714224, Lng: -73.961452}, + EnableAddressDescriptor: True + } + reverseGeocodingResponse, _, err := c.ReverseGeocode(context.Background(), r) + if err != nil { + log.Fatalf("fatal error: %s", err) + } + + pretty.Println(reverseGeocodingResponse) +} +``` + ## Features ### Rate limiting