Skip to content

Commit

Permalink
Narweb: clarify how to get the API_KEY
Browse files Browse the repository at this point in the history
Fixes #12646
  • Loading branch information
SNoiraud authored and Nick-Hall committed Jul 24, 2023
1 parent 5b540d6 commit e7e1b74
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion gramps/plugins/webreport/narrativeweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1891,6 +1891,7 @@ def __init__(self, name, dbase):
self.__googleopts = None
self.__googlemapkey = None
self.__olv = None
self.googlemapkeyhelp = None
self.__ancestortree = None
self.__css = None
self.__gallery = None
Expand Down Expand Up @@ -2491,8 +2492,23 @@ def __add_place_map_options(self, menu):
addopt("googleopts", self.__googleopts)

self.__googlemapkey = StringOption(_("Google maps API key"), "")
self.__googlemapkey.set_help(_("The API key used for the Google maps"))
self.__googlemapkey.set_help(_("The API key used for the Google maps.\n"
"This key is mandatory and must be valid"
))
if not config.is_set("paths.website-get-api-key"):
# The following will be used to change the URL if it changes without
# creating a patch. We will only need to change gramps.ini
config.register("paths.website-get-api-key",
"https://developers.google.com/maps/documentation/javascript/get-api-key")
keyvalue = config.get("paths.website-get-api-key")
self.googlemapkeyhelp = StringOption(_("How to get the API key"),
keyvalue)
self.googlemapkeyhelp.connect('value-changed', self.url_changed)
keytooltip = _("Copy and paste this value in your browser."
"\nThe Google maps service must be selected.")
self.googlemapkeyhelp.set_help(keytooltip)
addopt("googlemapkey", self.__googlemapkey)
addopt("googlemapkeyhelp", self.googlemapkeyhelp)

stamenopts = [
(_("Toner"), "toner"),
Expand Down Expand Up @@ -2840,8 +2856,18 @@ def __placemap_options(self):

if (place_active or family_active) and mapservice_opts == "Google":
self.__googlemapkey.set_available(True)
self.googlemapkeyhelp.set_available(True)
else:
self.__googlemapkey.set_available(False)
self.googlemapkeyhelp.set_available(False)

def url_changed(self):
"""
This value must be changed only if the url is modified.
"""
api_key_url = self.googlemapkeyhelp.get_value()
if api_key_url != "":
config.set("paths.website-get-api-key", api_key_url)

def __add_calendar_options(self, menu):
"""
Expand Down

0 comments on commit e7e1b74

Please sign in to comment.