parent
ce30c874d1
commit
ce4cd33139
@ -171,6 +171,10 @@ MARKERS = """
|
|||||||
}"""
|
}"""
|
||||||
|
|
||||||
# javascript for OpenStreetMap's markers...
|
# javascript for OpenStreetMap's markers...
|
||||||
|
"""
|
||||||
|
https://openlayers.org/en/latest/examples/
|
||||||
|
"""
|
||||||
|
|
||||||
OSM_MARKERS = """
|
OSM_MARKERS = """
|
||||||
function initialize(){
|
function initialize(){
|
||||||
var map;
|
var map;
|
||||||
@ -198,12 +202,56 @@ OSM_MARKERS = """
|
|||||||
style: iconStyle
|
style: iconStyle
|
||||||
});
|
});
|
||||||
var centerCoord = new ol.proj.transform([%s, %s], 'EPSG:4326', 'EPSG:3857');
|
var centerCoord = new ol.proj.transform([%s, %s], 'EPSG:4326', 'EPSG:3857');
|
||||||
map= new ol.Map({
|
map = new ol.Map({
|
||||||
target: 'map_canvas',
|
target: 'map_canvas',
|
||||||
layers: [new ol.layer.Tile({ source: new ol.source.OSM() }),
|
layers: [new ol.layer.Tile({ source: new ol.source.OSM() }),
|
||||||
markerLayer],
|
markerLayer],
|
||||||
view: new ol.View({ center: centerCoord, zoom: %d })
|
view: new ol.View({ center: centerCoord, zoom: %d })
|
||||||
});
|
});
|
||||||
|
"""
|
||||||
|
|
||||||
|
STAMEN_MARKERS = """
|
||||||
|
function initialize(){
|
||||||
|
var map;
|
||||||
|
var tracelife = %s;
|
||||||
|
var layer = '%s';
|
||||||
|
var iconStyle = new ol.style.Style({
|
||||||
|
image: new ol.style.Icon(({
|
||||||
|
//anchor: [0.5, 46],
|
||||||
|
anchorXUnits: 'fraction',
|
||||||
|
anchorYUnits: 'pixels',
|
||||||
|
opacity: 1.0,
|
||||||
|
src: marker_png
|
||||||
|
}))
|
||||||
|
});
|
||||||
|
var markerSource = new ol.Collection();
|
||||||
|
for (var i = 0; i < tracelife.length; i++) {
|
||||||
|
var loc = tracelife[i];
|
||||||
|
var iconFeature = new ol.Feature({
|
||||||
|
geometry: new ol.geom.Point(ol.proj.transform([loc[0], loc[1]],
|
||||||
|
'EPSG:4326', 'EPSG:3857')),
|
||||||
|
name: loc[2],
|
||||||
|
});
|
||||||
|
iconFeature.setStyle(iconStyle);
|
||||||
|
markerSource.push(iconFeature);
|
||||||
|
}
|
||||||
|
var centerCoord = new ol.proj.transform([%s, %s], 'EPSG:4326', 'EPSG:3857');
|
||||||
|
map = new ol.Map({
|
||||||
|
target: 'map_canvas',
|
||||||
|
layers: [
|
||||||
|
new ol.layer.Tile({ source: new ol.source.Stamen({
|
||||||
|
layer: layer
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
new ol.layer.Vector({ source: new ol.source.Vector({
|
||||||
|
features: markerSource })
|
||||||
|
})
|
||||||
|
],
|
||||||
|
view: new ol.View({ center: centerCoord, zoom: %d })
|
||||||
|
});
|
||||||
|
"""
|
||||||
|
|
||||||
|
OPENLAYER = """
|
||||||
var element = document.getElementById('popup');
|
var element = document.getElementById('popup');
|
||||||
var tooltip = new ol.Overlay({
|
var tooltip = new ol.Overlay({
|
||||||
element: element,
|
element: element,
|
||||||
|
@ -234,6 +234,7 @@ class NavWebReport(Report):
|
|||||||
self.mapservice = self.options['mapservice']
|
self.mapservice = self.options['mapservice']
|
||||||
self.googleopts = self.options['googleopts']
|
self.googleopts = self.options['googleopts']
|
||||||
self.googlemapkey = self.options['googlemapkey']
|
self.googlemapkey = self.options['googlemapkey']
|
||||||
|
self.stamenopts = self.options['stamenopts']
|
||||||
self.reference_sort = self.options['reference_sort']
|
self.reference_sort = self.options['reference_sort']
|
||||||
|
|
||||||
if self.use_home:
|
if self.use_home:
|
||||||
@ -2035,6 +2036,7 @@ class NavWebOptions(MenuReportOptions):
|
|||||||
|
|
||||||
mapopts = [
|
mapopts = [
|
||||||
[_("OpenStreetMap"), "OpenStreetMap"],
|
[_("OpenStreetMap"), "OpenStreetMap"],
|
||||||
|
[_("StamenMap"), "StamenMap"],
|
||||||
[_("Google"), "Google"]]
|
[_("Google"), "Google"]]
|
||||||
self.__mapservice = EnumeratedListOption(_("Map Service"),
|
self.__mapservice = EnumeratedListOption(_("Map Service"),
|
||||||
mapopts[0][1])
|
mapopts[0][1])
|
||||||
@ -2081,6 +2083,19 @@ class NavWebOptions(MenuReportOptions):
|
|||||||
self.__googlemapkey.set_help(_("The API key used for the Google maps"))
|
self.__googlemapkey.set_help(_("The API key used for the Google maps"))
|
||||||
addopt("googlemapkey", self.__googlemapkey)
|
addopt("googlemapkey", self.__googlemapkey)
|
||||||
|
|
||||||
|
stamenopts = [
|
||||||
|
(_("Toner"), "toner"),
|
||||||
|
(_("Terrain"), "terrain"),
|
||||||
|
(_("WaterColor"), "watercolor")]
|
||||||
|
self.__stamenopts = EnumeratedListOption(_("Stamen Option"),
|
||||||
|
stamenopts[0][1])
|
||||||
|
for trans, opt in stamenopts:
|
||||||
|
self.__stamenopts.add_item(opt, trans)
|
||||||
|
self.__stamenopts.set_help(
|
||||||
|
_("Select which option that you would like "
|
||||||
|
"to have for the Stamenmap Map pages..."))
|
||||||
|
addopt("stamenopts", self.__stamenopts)
|
||||||
|
|
||||||
self.__placemap_options()
|
self.__placemap_options()
|
||||||
|
|
||||||
def __add_others_options(self, menu):
|
def __add_others_options(self, menu):
|
||||||
@ -2266,6 +2281,11 @@ class NavWebOptions(MenuReportOptions):
|
|||||||
else:
|
else:
|
||||||
self.__mapservice.set_available(False)
|
self.__mapservice.set_available(False)
|
||||||
|
|
||||||
|
if mapservice_opts == "StamenMap":
|
||||||
|
self.__stamenopts.set_available(True)
|
||||||
|
else:
|
||||||
|
self.__stamenopts.set_available(False)
|
||||||
|
|
||||||
if family_active and mapservice_opts == "Google":
|
if family_active and mapservice_opts == "Google":
|
||||||
self.__googleopts.set_available(True)
|
self.__googleopts.set_available(True)
|
||||||
else:
|
else:
|
||||||
|
@ -74,7 +74,8 @@ from gramps.plugins.webreport.common import (get_first_letters, _KEYPERSON,
|
|||||||
get_index_letter, add_birthdate,
|
get_index_letter, add_birthdate,
|
||||||
primary_difference, FULLCLEAR,
|
primary_difference, FULLCLEAR,
|
||||||
_find_birth_date, _find_death_date,
|
_find_birth_date, _find_death_date,
|
||||||
MARKER_PATH, OSM_MARKERS,
|
MARKER_PATH, OPENLAYER,
|
||||||
|
OSM_MARKERS, STAMEN_MARKERS,
|
||||||
GOOGLE_MAPS, MARKERS, html_escape,
|
GOOGLE_MAPS, MARKERS, html_escape,
|
||||||
DROPMASTERS, FAMILYLINKS)
|
DROPMASTERS, FAMILYLINKS)
|
||||||
from gramps.plugins.webreport.layout import LayoutTree
|
from gramps.plugins.webreport.layout import LayoutTree
|
||||||
@ -455,6 +456,7 @@ class PersonPages(BasePage):
|
|||||||
self.mapservice = self.report.options['mapservice']
|
self.mapservice = self.report.options['mapservice']
|
||||||
self.googleopts = self.report.options['googleopts']
|
self.googleopts = self.report.options['googleopts']
|
||||||
self.googlemapkey = self.report.options['googlemapkey']
|
self.googlemapkey = self.report.options['googlemapkey']
|
||||||
|
self.stamenopts = self.report.options['stamenopts']
|
||||||
|
|
||||||
# decide if we will sort the birth order of siblings...
|
# decide if we will sort the birth order of siblings...
|
||||||
self.birthorder = self.report.options['birthorder']
|
self.birthorder = self.report.options['birthorder']
|
||||||
@ -702,7 +704,7 @@ class PersonPages(BasePage):
|
|||||||
src_js += "&key=" + self.googlemapkey
|
src_js += "&key=" + self.googlemapkey
|
||||||
head += Html("script", type="text/javascript",
|
head += Html("script", type="text/javascript",
|
||||||
src=src_js, inline=True)
|
src=src_js, inline=True)
|
||||||
else:
|
else: # OpenStreetMap, Stamen...
|
||||||
url = self.secure_mode
|
url = self.secure_mode
|
||||||
url += ("maxcdn.bootstrapcdn.com/bootstrap/3.3.7/"
|
url += ("maxcdn.bootstrapcdn.com/bootstrap/3.3.7/"
|
||||||
"css/bootstrap.min.css")
|
"css/bootstrap.min.css")
|
||||||
@ -777,8 +779,8 @@ class PersonPages(BasePage):
|
|||||||
['%s', %s, %s, %d]
|
['%s', %s, %s, %d]
|
||||||
];""" % (placetitle.replace("'", "\\'"), latitude, longitude, seq_)
|
];""" % (placetitle.replace("'", "\\'"), latitude, longitude, seq_)
|
||||||
|
|
||||||
# are we using OpenStreetMap?
|
# we are using OpenStreetMap, Stamen...
|
||||||
elif self.mapservice == "OpenStreetMap":
|
else:
|
||||||
tracelife += """
|
tracelife += """
|
||||||
[%f, %f, \'%s\']
|
[%f, %f, \'%s\']
|
||||||
];""" % (float(longitude), float(latitude), placetitle.replace("'", "\\'"))
|
];""" % (float(longitude), float(latitude), placetitle.replace("'", "\\'"))
|
||||||
@ -852,8 +854,8 @@ class PersonPages(BasePage):
|
|||||||
jsc += MARKERS % (tracelife, midx_, midy_,
|
jsc += MARKERS % (tracelife, midx_, midy_,
|
||||||
zoomlevel)
|
zoomlevel)
|
||||||
|
|
||||||
# we are using OpenStreetMap...
|
# we are using OpenStreetMap
|
||||||
else:
|
elif self.mapservice == "OpenStreetMap":
|
||||||
if midy_ is None:
|
if midy_ is None:
|
||||||
jsc += OSM_MARKERS % (tracelife,
|
jsc += OSM_MARKERS % (tracelife,
|
||||||
longitude,
|
longitude,
|
||||||
@ -861,6 +863,23 @@ class PersonPages(BasePage):
|
|||||||
else:
|
else:
|
||||||
jsc += OSM_MARKERS % (tracelife, midy_, midx_,
|
jsc += OSM_MARKERS % (tracelife, midy_, midx_,
|
||||||
zoomlevel)
|
zoomlevel)
|
||||||
|
jsc += OPENLAYER
|
||||||
|
# we are using StamenMap
|
||||||
|
elif self.mapservice == "StamenMap":
|
||||||
|
if midy_ is None:
|
||||||
|
jsc += STAMEN_MARKERS % (tracelife,
|
||||||
|
self.stamenopts,
|
||||||
|
longitude,
|
||||||
|
latitude,
|
||||||
|
10,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
jsc += STAMEN_MARKERS % (tracelife,
|
||||||
|
self.stamenopts,
|
||||||
|
midy_, midx_,
|
||||||
|
zoomlevel,
|
||||||
|
)
|
||||||
|
jsc += OPENLAYER
|
||||||
|
|
||||||
# if Google and Drop Markers are selected,
|
# if Google and Drop Markers are selected,
|
||||||
# then add "Drop Markers" button?
|
# then add "Drop Markers" button?
|
||||||
|
@ -63,8 +63,9 @@ from gramps.plugins.webreport.common import (get_first_letters, first_letter,
|
|||||||
alphabet_navigation, GOOGLE_MAPS,
|
alphabet_navigation, GOOGLE_MAPS,
|
||||||
primary_difference, _KEYPLACE,
|
primary_difference, _KEYPLACE,
|
||||||
get_index_letter, FULLCLEAR,
|
get_index_letter, FULLCLEAR,
|
||||||
MARKER_PATH, OSM_MARKERS, MARKERS,
|
MARKER_PATH, OPENLAYER,
|
||||||
html_escape)
|
OSM_MARKERS, STAMEN_MARKERS,
|
||||||
|
MARKERS, html_escape)
|
||||||
|
|
||||||
_ = glocale.translation.sgettext
|
_ = glocale.translation.sgettext
|
||||||
LOG = logging.getLogger(".NarrativeWeb")
|
LOG = logging.getLogger(".NarrativeWeb")
|
||||||
@ -310,6 +311,7 @@ class PlacePages(BasePage):
|
|||||||
self.placemappages = self.report.options['placemappages']
|
self.placemappages = self.report.options['placemappages']
|
||||||
self.mapservice = self.report.options['mapservice']
|
self.mapservice = self.report.options['mapservice']
|
||||||
self.googlemapkey = self.report.options['googlemapkey']
|
self.googlemapkey = self.report.options['googlemapkey']
|
||||||
|
self.stamenopts = self.report.options['stamenopts']
|
||||||
|
|
||||||
# begin PlaceDetail Division
|
# begin PlaceDetail Division
|
||||||
with Html("div", class_="content", id="PlaceDetail") as placedetail:
|
with Html("div", class_="content", id="PlaceDetail") as placedetail:
|
||||||
@ -379,7 +381,7 @@ class PlacePages(BasePage):
|
|||||||
src_js += "&key=" + self.googlemapkey
|
src_js += "&key=" + self.googlemapkey
|
||||||
head += Html("script", type="text/javascript",
|
head += Html("script", type="text/javascript",
|
||||||
src=src_js, inline=True)
|
src=src_js, inline=True)
|
||||||
else:
|
else: # OpenStreetMap, Stamen...
|
||||||
url = self.secure_mode
|
url = self.secure_mode
|
||||||
url += ("maxcdn.bootstrapcdn.com/bootstrap/3.3.7/"
|
url += ("maxcdn.bootstrapcdn.com/bootstrap/3.3.7/"
|
||||||
"css/bootstrap.min.css")
|
"css/bootstrap.min.css")
|
||||||
@ -428,18 +430,25 @@ class PlacePages(BasePage):
|
|||||||
latitude, longitude,
|
latitude, longitude,
|
||||||
10)
|
10)
|
||||||
|
|
||||||
else:
|
elif self.mapservice == "OpenStreetMap":
|
||||||
# OpenStreetMap (OSM) adds Longitude/ Latitude
|
|
||||||
# to its maps, and needs a country code in
|
|
||||||
# lowercase letters...
|
|
||||||
with Html("script", type="text/javascript") as jsc:
|
with Html("script", type="text/javascript") as jsc:
|
||||||
canvas += jsc
|
canvas += jsc
|
||||||
#param1 = xml_lang()[3:5].lower()
|
|
||||||
jsc += MARKER_PATH % marker_path
|
jsc += MARKER_PATH % marker_path
|
||||||
jsc += OSM_MARKERS % ([[float(longitude),
|
jsc += OSM_MARKERS % ([[float(longitude),
|
||||||
float(latitude),
|
float(latitude),
|
||||||
placetitle]],
|
placetitle]],
|
||||||
longitude, latitude, 10)
|
longitude, latitude, 10)
|
||||||
|
jsc += OPENLAYER
|
||||||
|
else: # STAMEN
|
||||||
|
with Html("script", type="text/javascript") as jsc:
|
||||||
|
canvas += jsc
|
||||||
|
jsc += MARKER_PATH % marker_path
|
||||||
|
jsc += STAMEN_MARKERS % ([[float(longitude),
|
||||||
|
float(latitude),
|
||||||
|
placetitle]],
|
||||||
|
self.stamenopts,
|
||||||
|
longitude, latitude, 10)
|
||||||
|
jsc += OPENLAYER
|
||||||
|
|
||||||
# add javascript function call to body element
|
# add javascript function call to body element
|
||||||
body.attr += ' onload = "initialize();" '
|
body.attr += ' onload = "initialize();" '
|
||||||
|
Loading…
Reference in New Issue
Block a user