13

We use Google Geocoding API to map address to Latitude and Longitude.

Here is the sample URL for encoding (which returns json) -

http://maps.googleapis.com/maps/api/geocode/json?address=Dallas&sensor=false

Message: OVER_QUERY_LIMIT

Ok, it makes sense, because we exceed over 2500 daily limit so we place API key like this -

http://maps.googleapis.com/maps/api/geocode/json?key=xxxxx&address=Dallas&sensor=false

Message: REQUEST_DENIED

I'm wondering where/how to place the API Key.

Win
  • 61,100
  • 13
  • 102
  • 181
  • Just to confirm, you have an API key for a business account - not a free key for using google maps api in general? – Matthew Aug 23 '13 at 19:35
  • Added info from here to my answer: https://developers.google.com/maps/documentation/business/clientside/ – Matthew Aug 23 '13 at 20:48
  • Just to articulate this, the developer console (API) key can only be used with the Google Maps client-side APIs. The call you're making is to the Google Maps Geocoding web service API, hence the `REQUEST_DENIED` response. – James A Webb Aug 28 '13 at 00:41
  • possible duplicate of [Google Direction APIs error: REQUEST_DENIED](https://stackoverflow.com/questions/46748233/google-direction-apis-error-request-denied) – geocodezip Oct 14 '17 at 22:46

1 Answers1

13

Looks like in version 3 you need to pass the ClientID in the URL and not a key as you do in the free version: https://developers.google.com/maps/articles/v2tov3#newkey

So your URL should look like: http://maps.googleapis.com/maps/api/geocode/json?client=xxxxx&address=Dallas&sensor=false

Not lucky enough to have a paid account so I cannot test - but I think that will get you on the correct path.

Relevant from this link: https://developers.google.com/maps/documentation/business/webservices/

Client ID

You must include your client ID in all API requests. Your client ID identifies you as a Maps API for Business customer and enables support and purchased quota for your application. Requests made without a client ID are not eligible for Maps API for Business benefits.

If you're switching from the free API services to a Maps API for Business implementation, you must remove the key parameter from your requests. Google Maps API web services will deny requests made with both a client ID and a key.

More information is available in the Authentication and Authorization chapter of this guide.

If you have lost your client ID, you can recover it by logging in to the support portal and clicking Maps: Add URLs from the links on the left of the page.

EDIT

For more information, including instructions on passing your client ID to the Earth API, v2 API, and the Maps API for Flash, please read Loading Client-side APIs.

If you have lost your client ID or cryptographic key, you can recover them by logging in to the support portal and clicking Maps: Add URLs from the links on the left of the page.

Matthew
  • 9,851
  • 4
  • 46
  • 77
  • 2
    We just finished chatting with Google on the phone. Unfortunately, we did not have Business Account for Geocoding which costs ***$17,000*** per year. Now we are talking with our client. Thank you so much for your help. – Win Aug 23 '13 at 21:36
  • To avoid the limits you an cache results within your application's database - depends on what you are geocoding (addresses which are infrequently the same - which basically means you need to shell out, or common locations frequently reused, which means you only have to only call google's API for new ones). – Matthew Aug 23 '13 at 21:53
  • Relevant: http://gis.stackexchange.com/questions/15052/how-to-avoid-google-map-geocode-limit – Matthew Aug 23 '13 at 21:54
  • @Matthew Can you please see this question it's regarding geocodr class api limitation https://stackoverflow.com/questions/54144432/is-there-any-difference-between-android-geocoder-class-and-google-geocoder-api – Sudhanshu Gaur Jan 16 '19 at 12:58