How To Create A Google Maps API Key

The Google Maps API Key Has Been Created!

Geolocator_EditionThe Caldera Forms Geolocation field add-on requires a Google API Places Web Services API key. Google provides many different types of APIs, each requiring enabling different services. It is very important that you provide in the processor settings a enabled key for Google API Places Web Services.

To create a key, login to your Google account and then go to the Google Cloud Platform Console. You must first create a project in the dashboard, you can do this from the projects drop-down inside of the top menu. See this document for detail instructions.

Once you have a project, go to that project’s dashboard. In the dashboard find the Go To APIs Overview link and click that. On the next screen click the Enable APIs button that has a plus sign next to it. This will take you to the APIs library. They have a lot of them, including many for maps, make sure you get the right one.

The best way to find the right one is to search for “Google Places API Web Service.” Click the link that comes up. This will take you to a screen that has a blue enable button with a play sign next to it.

Enable A Google API

Create Google Maps CredentialsCreate Google Maps CredentialsAfter a few seconds the API should show enabled. You know need to click the Credentials link int he left-side navigation. Then click the blue Create Credentials button. This will bring up a modal asking what type of key to create, select the first option “API Key.” This opens another modal asking what type of API key to create. You should select “Browser Key.”

At this point you might be really frustrated that no one at Google ever walked through this process and said, “wow this is super long and complicated!” and did something about it. I’m baffled as to how the recent redesign of their API dashboard made it so much less intuitive. So, sorry to put you through all this, but its necessary. Anyway, almost done.

At this point you need to give the key a name. The name doesn’t matter. You can optionally add restrictions for what what domains are allowed to use this key. You really should do this step because this API is rate-limited and someone could take your API key and re-use it.

If you use it, you probably want to enter your site like this: “https://yoursite.com/*” to whitelist all pages on your site. You shouldn’t put any subdomains or “www” in.

Click the blue  Create Key button. This should open a new modal that has your API key in it. Copy the key and rejoice. Save it somewhere so you never have to visit the Google Cloud Platform Dashboard ever again.

Then go back to the Caldera Forms editor and paste it into the Geolocation field’s API Key setting. Save your form!

The Caldera Forms Geolocation Field processor settings with the API key set

 

Why Doesn’t My Google Maps Geolocation Autocomplete Search Work?

Hopefully, at this point your form’s geolocation search field should work — IE when you type an address in it, you should see a list of matching addresses. If not, here are some steps to figure out why.

  • Is the page loaded over secure HTTPS? If not, this will not work. Every WordPress site should have a valid SSL certificate and force HTTPS, if you’re not yet, this is a good reason to do so.
  • Are you seeing an error in your JavaScript console? Open your JavaScript console, and try a search. If you see errors, you’ll need to resolve those.
    • If  you see an error like “CFinitAutoComplete is not a function” and no other JavaScript errors, you likely have a PHP error. At this point, logging PHP errors with WordPress’ debug log should expose some problems.
    • You may see errors not related to this add-on, but if they are fatal, they could prevent it from working.
    • You may see an error that your API key is invalid or your site is not allowed. If so, you have an invalid API key — possibly its not enabled or is for the wrong API. Or it could be that you have set up the domain restrictions improperly.
  • If you have no errors and it still doesn’t work. Please go to the network tab of your console and inspect the results of one of the requests to the Google API servers. They may list errors.

If you need help with this troubleshooting, please open a support ticket. Make sure to include a link to a page where we can see the form and reproduce the issue.