google maps geocode: I get a new API key and it cl

2019-09-09 15:40发布

问题:

I have a geocode library (makeKML.pm at MarginalHacks.com) which uses the Google Maps geocode API. It has stopped working because it was using v2 requests, so I've switched to v3, and I'm told my API key is invalid. So I login to their disastrously confusing cloud console and finally figure out how to make a new server API key. Again I try a request with the new key:

https://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=659+Valencia+St%2C+San+Francisco+CA&key=<<<my new API key here>>>

I keep getting:

<?xml version="1.0" encoding="UTF-8"?>
<GeocodeResponse>
 <status>REQUEST_DENIED</status>
 <error_message>The provided API key is invalid.</error_message>
</GeocodeResponse>

Any thoughts on what's going on, or how I can ensure that I'm using the right type of API key? I've turned on the Google Maps Geocode API in the cloud console and registered a new web app which is where I'm getting the server key I'm using.

回答1:

Your query works without a key

There is no key parameter to the Google Maps Geocoding Web Service; the documentation does state: "Maps API for Business users must include valid client and signature parameters with their Geocoding requests", but that is additional cost (a contract with Google), and not a "key".