meta data for this page
How to enable Google Maps API Key
Source : Support Need4Viz — KB #80 — Category : Online maps
Symptom
- Use a N4V Google maps component (Google Heatmap, Google Lat/Lon or Google Address map).
- A message “ For development purposes only ” may appear on the Google map
Environment
- SAP BusinessObjects Business Intelligence Platform : all 4.2/4.3 Webi versions
- Need4Viz : all version
Resolution
Usage of Google maps is allowed only within a Google API Key you have to generate for your own company.
The steps for generation of the Key can be found here ( you can dismiss the step “Add the API key to your request” ):
https://developers.google.com/maps/documentation/javascript/get-api-key
After the steps “Create API keys” and “Restrict API keys”, you can retrieve your key and follow the below steps to activate your N4V Google maps components :
- Edit the Need4Viz\nodejs\node_modules\custom_element\ce_libs\config.js file
- Set your google key in the “ GoogleKey ” parameter (put your key between quotes): [image: image]
- Save the config.js file
- Open a PowerShell window and launch the command “ pm2 start all ”
- Try your N4V Google maps component in Webi
You can get information about the pricing of Google maps usage here : https://mapsplatform.google.com/pricing/
Possible issues
If you get an error about the new created Google API Key, find below the Common Causes and Solutions:
- Invalid API Key:
- Incorrect API Key Restrictions:
- Cause: You might have set restrictions on your API key in the Google Cloud Console, and those restrictions are preventing it from being used on your website. Restrictions commonly include:
- HTTP Referrers: Your key is only allowed to be used on specific domains (e.g.,
example.com,www.example.com). If your website's domain doesn't match, the key will be rejected. - API Restrictions: Your key is only permitted to be used with specific APIs (e.g., Maps JavaScript API, Geocoding API). If the required API isn't enabled, the key won't work.
- Solution:
- Review Restrictions: Go to the Google Cloud Console (APIs & Services > Credentials), select your API key, and examine the "Key restrictions" section.
- Check HTTP Referrers: If you've restricted by HTTP referrers, make sure all the necessary domains (and subdomains) are listed correctly. You might need to add
localhostor127.0.0.1during development. - Check API Restrictions: Ensure that “Maps JavaScript API” is enabled as an allowed API.
- No Restrictions (Temporary): As a quick test, temporarily set the "Application restrictions" to "None" and "API restrictions" to "Don't restrict key". If it works, you know the issue lies with the restrictions. Remember to re-enable proper restrictions once you identify the correct settings.