Google API Key - eliranwong/UniqueBible GitHub Wiki

Introduction

Unique Bible App Desktop version support use of Google API Key for displaying Google Maps when users:

  • Read Exhaustive Library of Bible Locations articles with config flag "alwaysDisplayStaticMaps" disabled. With config."alwaysDisplayStaticMaps" set to False, UBA embeds a Google maps within Exhaustive Library of Bible Locations articles.

  • Create customised Google Maps with multiple bible locations pinned via UBA menu plugin "Bible Locations".

It is optional to get a Google Maps API Key. Without an API key, google maps can still be displayed, but with marks "For development purposes only" on it. It would be nice to get an API key to get rid of the marks.

Get a Google Maps API Key

Go to https://mapsplatform.google.com and click "Get Started".

At the time of writing this wiki page, Google offers $200 monthly usage credit for no charge:

enable_google_map_platform

The monthly usage credit should be enough for general use of UBA menu plugin "Bible Locations".

Configuration

After you created a Google Maps API key:

  1. Go to https://console.cloud.google.com/apis/dashboard
  2. Select "Credentials"
  3. Select "Show Key" at the right end of your newly created "Maps API Key"
  4. Copy your Maps API Key
  1. Select from menu "UniqueBible > Other Preferences > Enter Google API Key"
  1. Paste your Google Maps API Key into the entry field
  2. Select "OK".

Setting Key Restrictions

This is optional, but to enhance security and protect your API key from being potential misuse from others, you may want to set up key restrictions.

Below shows steps to allow your Maps API key to be used with Unique Bible App desktop / webtop version.

  1. Go to https://console.cloud.google.com/apis/dashboard
  2. Select "Credentials"
  3. Select your newly created "Maps API Key"
  1. In section "Application Restrictions", select HTTP referrers (web sites)"
  2. Select "Add Item"
  3. Enter __file_url__/[UniqueBibleApp_home_folder_path]/htmlResources/*

For example, in our example shown below, our Unique Bible App home folder path is "/Users/username/uniquebibleapp-webtop/UniqueBible".

Therefore, we entered "__file_url__//Users/username/uniquebibleapp-webtop/UniqueBible/htmlResources/*"

Remarks:

  • For webtop version users, the key restriction should be '__file_url__//config/UniqueBible/htmlResources/*'.

  • On Chrome OS, UBA desktop version is running on Crostini Linux container. Users need to enter the Linux path for Google Maps to be displayed on Study Window, like '__file_url__//home/username/uniquebibleapp-webtop/UniqueBible/htmlResources/*'. However, they also need to enter the file path recognised by the parent OS for Chrome browser on Chrome OS to open a Google Map. To locate the path, simply click the 'Web Browser' button to open a Google map. At first, the map may fail to be displayed. Copy the path from the link address field of the browser and add a restriction entry, like '__file_url__//media/fuse/crostini_xxxxxxxxxxxxxxxxxxxxx_termina_penguin/uniquebibleapp-webtop/UniqueBible/htmlResources/*'.

On Android devices, users, who run http-server version via Termux, need to set, e.g.:

localhost:8080/*

127.0.0.1:8080/*

[ip]:8080/*, where [ip] is the ip assigned to your Android device, if you want other people on the same network use the server running on your phone.

On Android devices, users, who run terminal mode via Termux, need to set:

__content_url__/com.termux.documents/document/*

  1. Do not forget to select "Save" to save the restriction you defined.

Read more at: https://developers.google.com/maps/documentation/javascript/get-api-key