Added table to the Family Map Reference section.

svn: r18552
This commit is contained in:
Rob G. Healey 2011-12-06 10:18:29 +00:00
parent 188b076fd0
commit 62f43acaad
2 changed files with 194 additions and 129 deletions

View File

@ -111,6 +111,114 @@ from gui.pluginmanager import GuiPluginManager
#------------------------------------------------ #------------------------------------------------
# constants # constants
#------------------------------------------------ #------------------------------------------------
familylinks = """
var tracelife = %s
function initialize() {
var myLatLng = new google.maps.LatLng(%s, %s);
var mapOptions = {
scrollwheel: false,
scaleControl: true,
panControl: true,
backgroundColor: '#000000',
zoom: %d,
center: myLatLng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
var flightPath = new google.maps.Polyline({
path: tracelife,
strokeColor: "#FF0000",
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
}"""
dropmarkers = """
var markers = [];
var iterator = 0;
var tracelife = %s
var map;
function initialize() {
var mapOptions = {
scaleControl: true,
zoomControl: true,
zoom: %d,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: new google.maps.LatLng(0, 0)
};
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
}
function drop() {
for (var i = 0; i < tracelife.length; i++) {
setTimeout(function() {
addMarker();
}, i * 1000);
}
}
function addMarker() {
var location = tracelife[iterator];
var myLatLng = new google.maps.LatLng(location[1], location[2]);
markers.push(new google.maps.Marker({
position: myLatLng,
map: map,
draggable: true,
title: location[0],
animation: google.maps.Animation.DROP
}));
iterator++;
}"""
markers = """
var tracelife = %s
var map;
function initialize() {
var mapOptions = {
scrollwheel: false,
scaleControl: true,
panControl: true,
backgroundColor: '#000000',
zoom: %d,
center: new google.maps.LatLng(0, 0),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
addMarkers();
}
function addMarkers() {
var bounds = new google.maps.LatLngBounds();
for (var i = 0; i < tracelife.length; i++) {
var location = tracelife[i];
var myLatLng = new google.maps.LatLng(location[1], location[2]);
var marker = new google.maps.Marker({
position: myLatLng,
draggable: true,
title: location[0],
map: map,
zIndex: location[3]
});
bounds.extend(myLatLng);
map.fitBounds(bounds);
}
}"""
# there is no need to add an ending "</script>",
# as it will be added automatically by libhtml()
# Translatable strings for variables within this plugin # Translatable strings for variables within this plugin
# gettext carries a huge footprint with it. # gettext carries a huge footprint with it.
AHEAD = _("Attributes") AHEAD = _("Attributes")
@ -649,7 +757,7 @@ class BasePage(object):
place_handle = place.get_handle() place_handle = place.get_handle()
# 0 = latitude, 1 = longitude, 2 - placetitle, # 0 = latitude, 1 = longitude, 2 - placetitle,
# 3 = place handle, 4 = event date # 3 = place handle, 4 = event date, 5 = event type
found = any(data[3] == place_handle for data in place_lat_long) found = any(data[3] == place_handle for data in place_lat_long)
if not found: if not found:
placetitle = place.get_title() placetitle = place.get_title()
@ -659,9 +767,8 @@ class BasePage(object):
latitude, longitude = conv_lat_lon(latitude, longitude, "D.D8") latitude, longitude = conv_lat_lon(latitude, longitude, "D.D8")
if latitude is not None: if latitude is not None:
event_date = event.get_date_object() event_date = event.get_date_object()
etype = event.get_type() etype = str(event.get_type())
if etype in [gen.lib.EventType.BIRTH, gen.lib.EventType.DEATH]: place_lat_long.append([latitude, longitude, placetitle, place_handle, event_date, etype])
place_lat_long.append([latitude, longitude, placetitle, place_handle, event_date])
def _get_event_place(self, person, ppl_handle_list, place_lat_long): def _get_event_place(self, person, ppl_handle_list, place_lat_long):
""" """
@ -4825,7 +4932,7 @@ class IndividualPage(BasePage):
number_markers = len(place_lat_long) number_markers = len(place_lat_long)
if number_markers > 1: if number_markers > 1:
for (lat, long, p, h, d) in place_lat_long: for (lat, long, p, h, d, etype) in place_lat_long:
xwidth.append(lat) xwidth.append(lat)
yheight.append(long) yheight.append(long)
xwidth.sort() xwidth.sort()
@ -4894,126 +5001,51 @@ class IndividualPage(BasePage):
# if the number of places is only 1, then use code from imported javascript? # if the number of places is only 1, then use code from imported javascript?
if number_markers == 1: if number_markers == 1:
dataline = place_lat_long[0] latitude, longitude, pname, handle, date, etype_ = place_lat_long[0]
latitude, longitude = dataline[0], dataline[1]
if self.mapservice == "Google": if self.mapservice == "Google":
jsc += google_jsc % (latitude, longitude) jsc += google_jsc % (latitude, longitude)
else: else:
jsc += openstreetmap_jsc % (latitude, longitude) jsc += openstreetmap_jsc % (latitude, longitude)
# number of markers is more than one... # number of markers > 1
else: else:
if self.mapservice == "Google": if self.mapservice == "Google":
tracelife = """[""" tracelife = """["""
seq_ = 1
for index in xrange(0, (number_markers - 1)): for index in xrange(0, (number_markers - 1)):
latitude, longitude, p, h, d = place_lat_long[index] latitude, longitude, placetitle, handle, date, etype = place_lat_long[index]
tracelife += """
if self.googleopts == "FamilyLinks":
tracelife += """
new google.maps.LatLng(%s, %s),""" % (latitude, longitude) new google.maps.LatLng(%s, %s),""" % (latitude, longitude)
latitude, longitude, p, h ,d = place_lat_long[-1] elif self.googleopts in ["Drop", "Markers"]:
tracelife += """ tracelife += """
['%s', %s, %s, %d],""" % (placetitle, latitude, longitude, seq_)
seq_ += 1
latitude, longitude, placetitle, handle ,date, etype = place_lat_long[-1]
if self.googleopts == "FamilyLinks":
tracelife += """
new google.maps.LatLng(%s, %s) new google.maps.LatLng(%s, %s)
];""" % (latitude, longitude) ];""" % (latitude, longitude)
elif self.googleopts in ["Drop", "Markers"]:
tracelife += """
['%s', %s, %s, %d]
];""" % (placetitle, latitude, longitude, seq_+1)
if self.googleopts == "FamilyLinks": if self.googleopts == "FamilyLinks":
jsc += """ jsc += familylinks % (tracelife, midX_, midY_, zoomlevel)
var tracelife = %s
function initialize() {
var myLatLng = new google.maps.LatLng(%s, %s);
var mapOptions = {
zoom: %d,
center: myLatLng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
var flightPath = new google.maps.Polyline({
path: tracelife,
strokeColor: "#FF0000",
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
}""" % (midX_, midY_, tracelife, zoomlevel)
# Google Drop Markers... # Google Drop Markers...
if self.googleopts == "Drop": if self.googleopts == "Drop":
jsc += """ jsc += dropmarkers % (tracelife, zoomlevel)
var centre = new google.maps.LatLng(%s, %s);
var markers = [];
var iterator = 0;
var tracelife = %s
var map;
function initialize() {
var mapOptions = {
scaleControl: true,
zoomControl: true,
zoom: %d,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: centre
};
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
}
function drop() {
for (var i = 0; i < neighborhoods.length; i++) {
setTimeout(function() {
addMarker();
}, i * 1000);
}
}
function addMarker() {
markers.push(new google.maps.Marker({
position: tracelife[iterator],
map: map,
draggable: true,
animation: google.maps.Animation.DROP
}));
iterator++;
}""" % (midX_, midY_, tracelife, zoomlevel)
# Google Maps Markers only... # Google Maps Markers only...
elif self.googleopts == "Markers": elif self.googleopts == "Markers":
jsc += """ jsc += markers % (tracelife, zoomlevel)
var centre = new google.maps.LatLng(%s, %s);
var tracelife = %s
var map;
function initialize() {
var mapOptions = {
scrollwheel: true,
scaleControl: true,
backgroundColor: '#000000',
zoom: %d,
center: centre,
mapTypeId: google.maps.MapTypeId.ROADMAP,
}
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
addMarkers();
}
function addMarkers() {
for (var iterator = 0; iterator < tracelife.length; iterator++) {
var marker = new google.maps.Marker({
position: tracelife[iterator],
draggable: true,
map: map
});
}
}""" % (midX_, midY_, tracelife, zoomlevel)
# there is no need to add an ending "</script>",
# as it will be added automatically by libhtml()
elif self.mapservice == "OpenStreetMap": elif self.mapservice == "OpenStreetMap":
jsc += """ jsc += """
@ -5074,10 +5106,11 @@ class IndividualPage(BasePage):
self.get_name(person)), inline=True) self.get_name(person)), inline=True)
# page message # page message
msg = _("This map page represents the person and their descendants only of their birth and death. " msg = _("This map page represents the person and their descendants with "
"The markers and the Reference list are sorted in chronological order. " "all of their event/ places. If you place your mouse over "
"Clicking on a place&#8217;s name in the Reference section will " "the marker it will display the place name. The markers and the Reference "
"take you to that page&#8217;s page.") "list are sorted in date order (if any?). Clicking on a place&#8217;s "
"name in the Reference section will take you to that place&#8217;s page.")
mapdetail += Html("p", msg, id = "description") mapdetail += Html("p", msg, id = "description")
# here is where the map is held in the CSS/ Page # here is where the map is held in the CSS/ Page
@ -5088,33 +5121,49 @@ class IndividualPage(BasePage):
if (self.mapservice == "Google" and self.googleopts == "Drop"): if (self.mapservice == "Google" and self.googleopts == "Drop"):
mapdetail += Html("button", _("Drop Markers"), id ="drop", onclick ="drop()", inline =True) mapdetail += Html("button", _("Drop Markers"), id ="drop", onclick ="drop()", inline =True)
# begin place reference section and its table...
with Html("div", class_ ="subsection", id ="references") as section: with Html("div", class_ ="subsection", id ="references") as section:
mapdetail += section mapdetail += section
section += Html("h4", _("References"), inline =True) section += Html("h4", _("References"), inline =True)
with Html("table", class_ ="infolist") as table:
section += table
thead = Html("thead")
table += thead
trow = Html("tr")
thead += trow
trow.extend(
Html("th", label, class_ =colclass, inline =True)
for (label, colclass) in [
(_("Place Title"), "ColumnName"),
(_("Date"), "ColumnDate"),
(_("Event Type"), "ColumnType") ]
)
tbody = Html("tbody")
table += tbody
ordered = Html("ol") # 0 = latitude, 1 = longitude, 2 = place title, 3 = handle, and 4 = date
section += ordered place_lat_long = sorted(place_lat_long, key =operator.itemgetter(4, 3, 0, 1))
for (latitude, longitude, placetitle, handle, date, etype) in place_lat_long:
# 0 = latitude, 1 = longitude, 2 = place title, 3 = handle, and 4 = date trow = Html("tr")
place_lat_long = sorted(place_lat_long, key =operator.itemgetter(4, 3, 0, 1)) tbody += trow
for (lat, long, pname, handle, date) in place_lat_long:
trow.extend(
list = Html("li", self.place_link(handle, pname, up =self.up)) Html("td", data, class_ =colclass)
ordered += list for data, colclass in [
(self.place_link(handle, placetitle, up =True), "ColumnName"),
if date: (date, "ColumnDate"),
ordered1 = Html("ol") (etype, "ColumnType")
list += ordered1 ]
)
list1 = Html("li", _dd.display(date), inline =True)
ordered1 += list1
# add body id for this page... # add body id for this page...
body.attr = 'id ="FamilyMap"' body.attr = 'id ="FamilyMap" onload ="initialize()"'
# add body onload to initialize map for Google Maps only...
if self.mapservice == "Google":
body.attr += ' onload ="initialize()"'
# add clearline for proper styling # add clearline for proper styling
# add footer section # add footer section

View File

@ -45,6 +45,22 @@ div#map_canvas {
width: 931px; width: 931px;
height: 1000px; height: 1000px;
} }
div#FamilyMapDeatail div#references table.infolist {
width: 100%;
}
div#FamilyMapDeatail div#references table.infolist thead tr th {
font-weight: bold;
font-size: .6em;
}
div#FamilyMapDeatail div#references table.infolist thead tr th.ColumnName {
width: 25%;
}
div#FamilyMapDeatail div#references table.infolist thead tr th.ColumnDate {
width: 20%;
}
div#FamilyMapDeatail div#references table.infolist thead tr th.ColumnType {
width: 10%;
}
/* Place Maps /* Place Maps
------------------------------------------------------ */ ------------------------------------------------------ */