From fc25f89ca0488ca3d0d48d966743d67e4b5da27c Mon Sep 17 00:00:00 2001 From: David Wu Date: Wed, 26 Aug 2015 17:12:55 +0800 Subject: [PATCH] add support for google maps api key --- geocode.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/geocode.go b/geocode.go index a22c2b1..6186e4b 100644 --- a/geocode.go +++ b/geocode.go @@ -23,7 +23,7 @@ const ( ROUTE RequestType = 2 /* Geocoding URLs */ - GOOGLE = "http://maps.googleapis.com/maps/api/geocode/json" + GOOGLE = "https://maps.googleapis.com/maps/api/geocode/json" OSM = "http://open.mapquestapi.com/nominatim/v1/reverse.php" /* Routing URLs */ @@ -63,6 +63,7 @@ type Request struct { Region string // used by GOOGLE Language string // used by GOOGLE Sensor bool // used by GOOGLE + ApiKey string // used by GOOGLE values url.Values } @@ -118,6 +119,9 @@ func (r *Request) Values() url.Values { if r.Language != "" { v.Set("language", r.Language) } + if r.ApiKey != "" { + v.Set("key", r.ApiKey) + } v.Set("sensor", strconv.FormatBool(r.Sensor)) case OSM: v.Set("limit", strconv.FormatInt(r.Limit, 10)) @@ -218,7 +222,8 @@ type Response struct { } type GoogleResponse struct { - Results []*GoogleResult + Results []*GoogleResult + ErrorMessage string `json:"error_message"` } type GoogleResult struct {