How to Create Google Maps API Keys for Ninja Forms Geolocation
Follow the steps below to create both the Server and Browser API keys required for integrating Google Maps with Geolocation for Ninja Forms. These API keys allow you to enable geolocation-based features such as address autocomplete, location fields, and map display within your Ninja Forms.
Step-by-Step Guide to Google Maps API Keys
1. Access the Google Cloud Console
- Go to the Google Cloud Console.
- Log in using your Google account credentials.
2. Create or Select a Google Cloud Project
- Click the Project Selector from the top navigation bar.
- Choose an existing project or click New Project to create a new one.
- Enter a project name and click Create.
3. Enable Google Maps API Services for Ninja Forms
- From the Google Cloud Dashboard, go to APIs & Services > Library.
- Search for and enable the following APIs:
- Maps JavaScript API
- Geocoding API
- Places API (Legacy) Enable Here
- Places API (New)
- Directions API (Legacy) Enable Here
- Routes API
- Maps Static API
- Geolocation API
- For each API, click on it and then select Enable.
Important Notice: Google has recently introduced new API services, replacing the Places API (Legacy) with the Places API (New) and integrating the Directions API into the Routes API.
Currently, Geolocation for Ninja Forms is not yet fully compatible with the new APIs. Until an update is available, you must enable both the new APIs (Places API (New) and Routes API) as well as the legacy APIs by manually visiting the links below:
- Enable Places API (Legacy): Click Here
- Enable Directions API (Legacy): Click Here
A future plugin update will provide full compatibility with the new API services.
4. Generate & Restrict Your Browser API Key
- Go to APIs & Services > Credentials.
- Click + Create Credentials > API Key.
- Your new API key will be generated. Copy it for later use.
- Click Restrict Key and apply the following settings:
- Application restrictions: Choose HTTP referrers (websites).
- Add your website domain (e.g.,
https://example.com/*
). - API restrictions: Enable Maps JavaScript API, Places API, and Geocoding API.
- Save the changes.
5. Generate & Secure Your Server API Key
- While in the Credentials section, click + Create Credentials > API Key.
- Another API key will be generated. Copy and save it.
- Click Restrict Key and apply the following settings:
- Application restrictions: Select IP addresses.
- Add your server's IP address.
- API restrictions: Enable Geocoding API and Places API.
- Save your changes.
How Geolocation Works in Ninja Forms
By enabling Google Maps API services, Geolocation for Ninja Forms enhances form functionality with features like:
- Address Autocomplete: Suggests addresses in real-time as users type.
- Map Field: Allows users to select locations directly on an interactive map.
- Geolocation Data: Automatically captures location coordinates from entered addresses.
Final Notes on API Key Setup
Ensuring that your Google Maps API keys are correctly configured is essential for smooth operation of geolocation features within Ninja Forms.
If you experience any issues:
- Verify that all required APIs are enabled in the Google Cloud Console.
- Check that your API keys have the correct restrictions applied.
- Make sure the Geocoding API and Places API are active.
For further assistance, visit the Google Maps API Documentation or contact Ninja Forms Geolocation support.