diff --git a/gramps/plugins/webreport/narrativeweb.py b/gramps/plugins/webreport/narrativeweb.py index bfddf760f..c6ff3d2eb 100644 --- a/gramps/plugins/webreport/narrativeweb.py +++ b/gramps/plugins/webreport/narrativeweb.py @@ -151,7 +151,7 @@ SORT_KEY = glocale.sort_key #------------------------------------------------ # constants #------------------------------------------------ -GOOGLE_MAPS = 'http://maps.googleapis.com/maps/' +GOOGLE_MAPS = 'https://maps.googleapis.com/maps/' # javascript code for marker path MARKER_PATH = """ var marker_png = '%s' @@ -3923,6 +3923,7 @@ class PlacePages(BasePage): self.placemappages = self.report.options['placemappages'] self.mapservice = self.report.options['mapservice'] + self.googlemapkey = self.report.options['googlemapkey'] # begin PlaceDetail Division with Html("div", class_="content", id="PlaceDetail") as placedetail: @@ -3988,6 +3989,8 @@ class PlacePages(BasePage): # add MapService specific javascript code src_js = GOOGLE_MAPS + "api/js?sensor=false" if self.mapservice == "Google": + if self.googlemapkey: + src_js += "&key=" + self.googlemapkey head += Html("script", type="text/javascript", src=src_js, inline=True) else: @@ -6002,6 +6005,7 @@ class PersonPages(BasePage): self.mapservice = None self.sort_name = None self.googleopts = None + self.googlemapkey = None self.birthorder = None self.person = None self.familymappages = None @@ -6312,6 +6316,7 @@ class PersonPages(BasePage): self.placemappages = self.report.options['placemappages'] self.mapservice = self.report.options['mapservice'] self.googleopts = self.report.options['googleopts'] + self.googlemapkey = self.report.options['googlemapkey'] # decide if we will sort the birth order of siblings... self.birthorder = self.report.options['birthorder'] @@ -6551,7 +6556,9 @@ class PersonPages(BasePage): # add MapService specific javascript code if self.mapservice == "Google": - src_js = "http://maps.googleapis.com/maps/api/js?sensor=false" + src_js = GOOGLE_MAPS + "api/js?sensor=false" + if self.googlemapkey: + src_js += "&key=" + self.googlemapkey head += Html("script", type="text/javascript", src=src_js, inline=True) else: @@ -8101,6 +8108,7 @@ class NavWebReport(Report): self.familymappages = self.options['familymappages'] self.mapservice = self.options['mapservice'] self.googleopts = self.options['googleopts'] + self.googlemapkey = self.options['googlemapkey'] if self.use_home: self.index_fname = "index" @@ -9352,6 +9360,7 @@ class NavWebOptions(MenuReportOptions): self.__placemappages = None self.__familymappages = None self.__googleopts = None + self.__googlemapkey = None self.__ancestortree = None self.__css = None self.__dl_descr1 = None @@ -9713,8 +9722,8 @@ class NavWebOptions(MenuReportOptions): addopt = partial(menu.add_option, category_name) mapopts = [ - [_("Google"), "Google"], - [_("OpenStreetMap"), "OpenStreetMap"]] + [_("OpenStreetMap"), "OpenStreetMap"], + [_("Google"), "Google"]] self.__mapservice = EnumeratedListOption(_("Map Service"), mapopts[0][1]) for trans, opt in mapopts: @@ -9756,6 +9765,10 @@ class NavWebOptions(MenuReportOptions): "to have for the Google Maps Family Map pages...")) addopt("googleopts", self.__googleopts) + self.__googlemapkey = StringOption(_("Google maps API key"),"") + self.__googlemapkey.set_help(_("The API key used for the Google maps")) + addopt("googlemapkey", self.__googlemapkey) + self.__placemap_options() def __add_others_options(self, menu): @@ -9930,6 +9943,11 @@ class NavWebOptions(MenuReportOptions): else: self.__googleopts.set_available(False) + if (place_active or family_active) and mapservice_opts == "Google": + self.__googlemapkey.set_available(True) + else: + self.__googlemapkey.set_available(False) + # FIXME. Why do we need our own sorting? Why not use Sort? def sort_people(dbase, handle_list): """