Frequently Asked Question

How to enable Google Maps API Key
Last Updated 10 months ago

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 :

  1. Edit the Need4Viz\nodejs\node_modules\custom_element\ce_libs\config.js file
  2. Set your google key in the "GoogleKey" parameter (put your key between quotes): image
  3. Save the config.js file
  4. Open a PowerShell window and launch the command "pm2 start all"
  5. 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:
    • Cause: The most likely problem. The key you're using might be incorrect, mistyped, or no longer valid.
    • Solution:
      • Verify: Double-check that you've copied the key correctly from your Google Cloud Console.
      • Regenerate: If you suspect the key has been compromised or you're unsure if it's the right one, generate a new API key in the Google Cloud Console (APIs & Services > Credentials).
      • Check the key: Verify if you have enabled the Google maps API in the google cloud console, where you created the 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 localhost or 127.0.0.1 during 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.

Please Wait!

Please wait... it will take a second!