Generate And Setup Google Maps API Keys
* Note, this tutorial in some steps refers to the GEO my WP plugin. However, the steps to create the API keys are the same for other geolocation plugins as well. Make sure to enter the Google API keys that you create in the settings page of your plugin.
Follow the steps below to create both server and browser ( client-side ) Google Maps API keys for GEO my WP plugin ( or for your other projects ), and to enable the required API services.
- Navigate to the Google Maps Platform and Click 'Get Started'.
- Check the 'Maps', 'Routes' and 'Places' checkboxes and click Continue.
- Either select an existing project or create a new project. If you are creating a new project, you will need to enter a name for it, for example, "GEO my WP Maps API Keys". Click 'Next' when you are done.
- At this point, if you don't already have a billing account, you will need to create one. If you do need an account, click 'Set Account' and follow all the steps to create the billing account ( those steps are not mentioned in the tutorial ).
- Click Next to create your first API key.
- Your first API key is now ready. Copy the newly generated API key ( you'll need this to enter in the settings page of your plugin later ) and click the API Console link to set it up. We will set up this key as a browser ( client-side ) key.
- Enter a name for this API key in the 'Name' input box. Since this will be your browser's key, you can name it something like "GEO my WP Browser key.
- Scroll down that same page. In Application Restriction select 'HTTP Referrers' and enter your website's domain in the input box. For example, mysite.com/*. When you are done, click 'Save'. You will then be redirected to the Credentials page where you will see your new API key.
- Now we need to create a server API key. In the Credentials page click 'Create credentials' then click 'API Key' from the list.
- You have now created a new API key. Click "Restrict Key" to set it up as a server key.
- Enter a name for this API key in the 'Name' input box. Since this will be your server key, you can name it something like "GEO my WP Server key.
- Scroll down that same page. In Application Restriction select 'IP addresses (web servers,
cronjobs, etc.)' then enter your server's IP address in the input box. When you are done, click 'Save'.
- Now we need to enable the required API services. Click 'Dashboard' on the menu to the left.
- Scroll down to check if all the required API services enabled. By default, all the Map API services should be enabled. The required API services you need to look for listed below:
- Directions API
- Distance Matrix API
- Geocoding API
- Geolocation API
- Places API
- Roads API
- Street View API
- If any of the API services are missing or disabled, you'll need to enable them. To do so, click the 'Enable APIs and services' button.
- Now you can either type and search for specific API/service, or click 'view all' in the 'Maps' category to view all the map services.
- Find the specific API that you would like to enable and click on its box.
- Click 'Enable' to enable the API service.
- Repeat steps 11 to 14 to enable all the required API services that were mentioned in step 10.