Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
We started running into denials from the Google Geocoding JSON Service. It turns out that the google geocoder in the location module is not using an API key for requests even when one is provided. I will attach a patch that resolved the issue for us and got geocoding going again with an API key.
Comment | File | Size | Author |
---|---|---|---|
#8 | location-googlegeocoderapikey-2219543-8.patch | 3.57 KB | onelittleant |
#1 | location-googlegeocoderapikey-2219543-1.patch | 773 bytes | onelittleant |
Comments
Comment #1
onelittleant CreditAttribution: onelittleant commentedComment #2
onelittleant CreditAttribution: onelittleant commentedComment #4
JKingsnorth CreditAttribution: JKingsnorth commentedI can confirm this bug. Even though the module grabs our API key from the GMAP module, it doesn't actually USE it in the request!
Comment #5
JKingsnorth CreditAttribution: JKingsnorth commentedI can confirm that the patch in #1 does work, but I'm not sure it is the right approach.
Surely the API key should be set into the variable
location_geocode_google_apikey
regardless of whether it comes from GMAP or is set in the location module. It looks like the admin settings form options is supposed to do this:But it doesn't work. My API key is set via GMAP, and the
location_geocode_google_apikey
variable is empty. It is not empty if there is an API key set on the location module though, ie when the second form is active. But obviously the first part is not working properly. I think we should try to fix that and kill two birds with one stone.Comment #6
JKingsnorth CreditAttribution: JKingsnorth commentedOK, so that first bit of the form, that is suppoed to detect the GMAP API key and set it to the variable is doing nothing useful:
Issue 1 - The 'item' type can't have a value, so nothing is being set here.
Issue 2 - Even if we change this to a 'textfield' with the value from the GMAP module's API key, the value isn't set to the
location_geocode_google_apikey
variable until an admin goes to one of these configuration pages (Location > Geocoding options > Next to a country - Configure parameters) and hits 'Save configuration'.So we need to somehow get this variable to be set by default if the GMAP module's API key is set? I guess this would have to hook in to the install process, and hook in to the form in the GMAP module where the API key is saved? Or we abandon trying to use the GMAP module's API key altogether, and just set it again in Location.
Comment #7
onelittleant CreditAttribution: onelittleant commentedWith Google Maps API 3.x an API key is not needed. Also, the API key needed for geocoding should now be different than any browser api key. It should be a server key generated through the Google developers console. This is tied to limits and billing.
I would think the best approach to preserve backward compatibility would be to always show the API key field on the Location settings and in the code use the gmap API key if nothing is set in the Location geocoder API key.
Comment #8
onelittleant CreditAttribution: onelittleant commentedThis patch includes some updates based on suggestion from John https://drupal.org/comment/8611387#comment-8611387 and an API key for test bot.
Comment #9
podarok#8 commited
thanks!
Comment #12
gpvdo CreditAttribution: gpvdo commentedIt sounds like location is getting the API key from 'gmap' module.
Since Location module will do geo-coding without the 'gmap' module, should it not have its own entry for the Google Maps API?