- Notifications
You must be signed in to change notification settings - Fork225
Go client library for Google Maps API Web Services
License
googlemaps/google-maps-services-go
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Use Go? This library brings manyGoogle Maps Platform Web Services APIs to your Go application.
The Go Client for Google Maps Services is a Go Client library for the following Google Maps PlatformAPIs:
- Directions API
- Distance Matrix API
- Elevation API
- Geocoding API
- Places API
- Roads API
- Time Zone API
- Maps Static API
Tip
See theGoogle Maps Platform Cloud Client Library for Go for our newer APIsincluding Address Validation API, Datasets API, Fleet Engine, new Places API, and Routes API.
- Go 1.7 or later.
- A Google Maps PlatformAPI key from a project with the APIs below enabled.
Important
This key should be kept secret on your server.
To install the Go Client for Google Maps Services, please execute the followinggo get command.
go get googlemaps.github.io/maps
View thereference documentation.
Additional documentation about the APIs is available at:
- Directions API
- Distance Matrix API
- Elevation API
- Geocoding API
- Places API
- Time Zone API
- Roads API
- Maps Static API
Sample usage of the Directions API with an API key:
package mainimport ("context""log""github.com/kr/pretty""googlemaps.github.io/maps")funcmain() {c,err:=maps.NewClient(maps.WithAPIKey("Insert-API-Key-Here"))iferr!=nil {log.Fatalf("fatal error: %s",err)}r:=&maps.DirectionsRequest{Origin:"Sydney",Destination:"Perth",}route,_,err:=c.Directions(context.Background(),r)iferr!=nil {log.Fatalf("fatal error: %s",err)}pretty.Println(route)}
Sample usage of the Geocoding API with an API key to get anAddress Descriptor:
package mainimport ("context""log""github.com/kr/pretty""googlemaps.github.io/maps")funcmain() {c,err:=maps.NewClient(maps.WithAPIKey("Insert-API-Key-Here"))iferr!=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)iferr!=nil {log.Fatalf("fatal error: %s",err)}pretty.Println(reverseGeocodingResponse)}
Never sleep between requests again! By default, requests are sent at the expected rate limits foreach web service, typically 50 queries per second for free users. If you want to speed up or slowdown requests, you can do that too, usingmaps.NewClient(maps.WithAPIKey(apiKey), maps.WithRateLimit(qps)).
Native objects for each of the API responses.
It's possible to get metrics for status counts and latency histograms for monitoring.Usemaps.WithMetricReporter(metrics.OpenCensusReporter{}) to log metrics to OpenCensus,andmetrics.RegisterViews() to make the metrics available to be exported.OpenCensus can export these metrics to avariety of monitoring services.You can also implement your own metric reporter instead of using the provided one.
This library uses Google Maps Platform services, and any use of Google Maps Platform is subject to theTerms of Service.
For clarity, this library, and each underlying component, is not a Google Maps Platform Core Service.
This library is offered via an open source license. It is not governed by the Google Maps Platform SupportTechnical Support Services Guidelines, theSLA, or theDeprecation Policy (however, any Google Maps Platform services used by the library remain subject to the Google Maps Platform Terms of Service).
This library adheres tosemantic versioning to indicate when backwards-incompatible changes are introduced.
If you find a bug, or have a feature request, pleasefile an issue on GitHub. If you would like to get answers to technical questions from other Google Maps Platform developers, ask through one of ourdeveloper community channels. If you'd like to contribute, please check theContributing guide.
You can also discuss this library on ourDiscord server.
About
Go client library for Google Maps API Web Services
Topics
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.