Finished up with Family Map Pages' map. Fixed the Place Maps' tab options.

svn: r17938
This commit is contained in:
Rob G. Healey 2011-07-19 06:12:44 +00:00
parent f8d698aecb
commit 531bf3a78f
3 changed files with 125 additions and 190 deletions

View File

@ -647,7 +647,7 @@ class BasePage(object):
global place_lat_long global place_lat_long
placetitle = place.get_title() placetitle = place.get_title()
latitude = longitude = "" latitude, longitude = "", ""
found = any(p[2] == placetitle for p in place_lat_long) found = any(p[2] == placetitle for p in place_lat_long)
if not found: if not found:
@ -658,8 +658,7 @@ class BasePage(object):
place.long, place.long,
"D.D8") "D.D8")
# 0 = latitude, 1 = longitude, 2 = place title, 3 = handle, # 0 = latitude, 1 = longitude, 2 = place title, 3 = handle, 4 = event date
# 4 = event date
place_lat_long.append([ latitude, longitude, place_lat_long.append([ latitude, longitude,
placetitle, place.handle, placetitle, place.handle,
event.get_date_object() ]) event.get_date_object() ])
@ -2533,7 +2532,6 @@ class PlacePage(BasePage):
self.placemappages = self.report.options['placemappages'] self.placemappages = self.report.options['placemappages']
self.googlemap = self.report.options['placemappages'] self.googlemap = self.report.options['placemappages']
self.openstreetmap = self.report.options['openstreetmap'] self.openstreetmap = self.report.options['openstreetmap']
self.wikimapia = self.report.options['wikimapia']
# begin PlaceDetail Division # begin PlaceDetail Division
with Html("div", class_ = "content", id = "PlaceDetail") as placedetail: with Html("div", class_ = "content", id = "PlaceDetail") as placedetail:
@ -2580,7 +2578,7 @@ class PlacePage(BasePage):
# call_generate_page(report, title, place_handle, src_list, head, body, place, placedetail) # call_generate_page(report, title, place_handle, src_list, head, body, place, placedetail)
# add place map here # add place map here
if ((self.placemappages or self.openstreetmap or self.wikimapia) and if ((self.placemappages or self.openstreetmap) and
(place and (place.lat and place.long) ) ): (place and (place.lat and place.long) ) ):
# get reallatitude and reallongitude from place # get reallatitude and reallongitude from place
@ -2588,13 +2586,13 @@ class PlacePage(BasePage):
place.long, place.long,
"D.D8") "D.D8")
# add Mapstraction CSS # add narrative-maps CSS...
fname = "/".join(["styles", "mapstraction.css"]) fname = "/".join(["styles", "narrative-maps.css"])
url = self.report.build_url_fname(fname, None, self.up) url = self.report.build_url_fname(fname, None, self.up)
head += Html("link", href = url, type = "text/css", media = "screen", rel = "stylesheet") head += Html("link", href = url, type = "text/css", media = "screen", rel = "stylesheet")
# add googlev3 specific javascript code # add googlev3 specific javascript code
if (self.googlemap and (not self.openstreetmap and not self.wikimapia) ): if self.googlemap:
head += Html("script", type ="text/javascript", head += Html("script", type ="text/javascript",
src ="http://maps.googleapis.com/maps/api/js?sensor=false", inline =True) src ="http://maps.googleapis.com/maps/api/js?sensor=false", inline =True)
@ -2609,15 +2607,11 @@ class PlacePage(BasePage):
with Html("div", id = "middle") as middle: with Html("div", id = "middle") as middle:
mapstraction += middle mapstraction += middle
if (self.openstreetmap or self.wikimapia): if self.openstreetmap:
url = 'http://www.openstreetmap.com/?lat=%s&lon=%s&zoom=11&layers=M' % ( url = 'http://www.openstreetmap.com/?lat=%s&lon=%s&zoom=11&layers=M' % (
latitude, longitude) latitude, longitude)
middle += Html("object", data = url, inline = True) middle += Html("object", data = url, inline = True)
url = 'http://wikimapia.org/#lat=%s&lon=%s&z=11&l=0&m=a&v=2' % (
latitude, longitude)
middle += Html("object", data = url, inline = True)
elif self.googlemap: elif self.googlemap:
# begin inline javascript code # begin inline javascript code
# because jsc is a string, it does NOT have to be properly indented # because jsc is a string, it does NOT have to be properly indented
@ -4056,6 +4050,10 @@ class IndividualPage(BasePage):
if not place_lat_long: if not place_lat_long:
return return
self.placemappages = self.report.options['placemappages']
self.googlemap = self.report.options['placemappages']
self.openstreetmap = self.report.options['openstreetmap']
minX, maxX = "0.00000001", "0.00000001" minX, maxX = "0.00000001", "0.00000001"
minY, maxY = "0.00000001", "0.00000001" minY, maxY = "0.00000001", "0.00000001"
XCoordinates, YCoordinates = [], [] XCoordinates, YCoordinates = [], []
@ -4095,8 +4093,8 @@ class IndividualPage(BasePage):
# define largeset of Y and X span for span variables # define largeset of Y and X span for span variables
largeset = set(xrange(-81, 82)) - middleset - smallset largeset = set(xrange(-81, 82)) - middleset - smallset
# sort place_lat_long based on chronological date order # sort place_lat_long based on date, latitude, longitude order...
place_lat_long = sorted(place_lat_long, key = operator.itemgetter(4, 2, 0)) place_lat_long = sorted(place_lat_long, key = operator.itemgetter(4, 0, 1))
of = self.report.create_file(person.handle, "maps") of = self.report.create_file(person.handle, "maps")
self.up = True self.up = True
@ -4107,60 +4105,66 @@ class IndividualPage(BasePage):
# if active # if active
# call_(report, up, head) # call_(report, up, head)
# add Mapstraction CSS # add narrative-maps stylesheet...
fname = "/".join(["styles", "mapstraction.css"]) fname = "/".join(["styles", "narrative-maps.css"])
url = self.report.build_url_fname(fname, None, self.up) url = self.report.build_url_fname(fname, None, self.up)
head += Html("link", href =url, type ="text/css", media ="screen", rel ="stylesheet") head += Html("link", href =url, type ="text/css", media ="screen", rel ="stylesheet")
# add googlev3 specific javascript code if self.placemappages:
head += Html("script", type = "text/javascript", head += Html("script", type ="text/javascript",
src = "http://maps.google.com/maps/api/js?sensor=false", inline = True) src ="http://maps.googleapis.com/maps/api/js?sensor=false", inline =True)
# set zoomlevel for size of map # set zoomlevel for size of map
# the smaller the span is, the larger the zoomlevel must be...
if spanY in smallset: if spanY in smallset:
zoomlevel = 12 zoomlevel = 13
elif spanY in middleset: elif spanY in middleset:
zoomlevel = 7 zoomlevel = 5
elif spanY in largeset: elif spanY in largeset:
zoomlevel = 4 zoomlevel = 3
else: else:
zoomlevel = 4 zoomlevel = 3
# begin inline javascript code # begin inline javascript code
# because jsc is a string, it does NOT have to properly indented # because jsc is a string, it does NOT have to properly indented
with Html("script", type = "text/javascript") as jsc: with Html("script", type ="text/javascript") as jsc:
head += jsc head += jsc
jsc += """ jsc += """
var mapCenter = new google.maps.LatLng(%s, %s); function initialize() {
var map; var myLatLng = new google.maps.LatLng(%s, %s);
var myOptions = {
zoom: %d,
center: myLatLng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
function initialize() { var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var mapOptions = {
zoom: %d,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: mapCenter
};
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);""" % ( var lifeHistory = [""" % (centerX, centerY, zoomlevel)
centerX, centerY, zoomlevel) for index in xrange(0, (number_markers - 1)):
for (latitude, longitude, p, h, d) in place_lat_long: data = place_lat_long[index]
jsc += """ latitude, longitude = conv_lat_lon(data[0], data[1], "D.D8")
addMarker(%s, %s);""" % (latitude, longitude) jsc += """ new google.maps.LatLng(%s, %s),""" % (latitude, longitude)
jsc += """ data = place_lat_long[-1]
} latitude, longitude = conv_lat_lon(data[0], data[1], "D.D8")
function addMarker(latitude, longitude) { jsc += """ new google.maps.LatLng(%s, %s)
var latlong = new google.maps.LatLng(latitude, longitude); ];
var flightPath = new google.maps.Polyline({
path: lifeHistory,
strokeColor: "#FF0000",
strokeOpacity: 1.0,
strokeWeight: 2
});
var markers = new google.maps.Marker({ flightPath.setMap(map);
position: latlong, }""" % (latitude, longitude)
map: map,
draggable: true,
animation: google.maps.Animation.BOUNCE # there is no need to add an ending "</script>",
}); # as it will be added automatically!
}"""
# there is no need to add an ending "</script>", # add body onload to initialize map
# as it will be added automatically! body.attr = 'onload ="initialize()" id ="FamilyMap" '
with Html("div", class_ ="content", id ="FamilyMapDetail") as mapbackground: with Html("div", class_ ="content", id ="FamilyMapDetail") as mapbackground:
body += mapbackground body += mapbackground
@ -4175,40 +4179,33 @@ class IndividualPage(BasePage):
mapbackground += Html("p", msg, id = "description") mapbackground += Html("p", msg, id = "description")
# set map dimensions based on span of Y Coordinates # set map dimensions based on span of Y Coordinates
ymap = "" if spanY in largeset:
if spanY in smallset: Ywidth = 1600
ymap = "small"
elif spanY in middleset: elif spanY in middleset:
ymap = "middle" Ywidth = 1200
elif spanY in largeset: elif spanY in smallset:
ymap = "large" Ywidth = 800
ymap += "YMap" else:
Ywidth = 800
# begin Ymap division if spanX in largeset:
with Html("div", id =ymap) as ymap: Xheight = 1600
mapbackground += ymap elif spanX in middleset:
Xheight = 1200
xmap = "" elif spanX in smallset:
if spanX in smallset: Xheight = 800
xmap = "small" else:
elif spanX in middleset: Xheight = 800
xmap = "middle"
elif spanX in largeset:
xmap = "large"
xmap += "XMap"
# begin Xmap division
with Html("div", id =xmap) as xmap:
ymap += xmap
# here is where the map is held in the CSS/ Page
with Html("div", id ="map_canvas") as canvas:
xmap += canvas
canvas += Html("button", _("Drop Markers"), id ="drop", onclick ="drop()", inline =True) # here is where the map is held in the CSS/ Page
canvas = Html("div", id ="map_canvas")
# add fullclear for proper styling mapbackground += canvas
canvas += fullclear
# add dynamic style to the place holder...
canvas.attr += ' style ="width:%dpx; height:%dpx; border: double 4px #000;" ' % (Ywidth, Xheight)
# add fullclear for proper styling
canvas += fullclear
with Html("div", class_ ="subsection", id ="references") as section: with Html("div", class_ ="subsection", id ="references") as section:
mapbackground += section mapbackground += section
@ -4230,9 +4227,6 @@ class IndividualPage(BasePage):
list1 = Html("li", _dd.display(date), inline = True) list1 = Html("li", _dd.display(date), inline = True)
ordered1 += list1 ordered1 += list1
# add body onload to initialize map
body.attr = 'onload = "initialize()" id = "FamilyMap"'
# add clearline for proper styling # add clearline for proper styling
# add footer section # add footer section
footer = self.write_footer() footer = self.write_footer()
@ -4785,9 +4779,6 @@ class IndividualPage(BasePage):
db = self.report.database db = self.report.database
self.familymappages = self.report.options['familymappages'] self.familymappages = self.report.options['familymappages']
self.fgooglemap = self.report.options['familymappages'] self.fgooglemap = self.report.options['familymappages']
#self.fopenstreetmap = self.report.options['fopenstreetmap']
#self.fwikimapia = self.report.options['fwikimapia']
# begin parents division # begin parents division
with Html("div", class_ = "subsection", id = "parents") as section: with Html("div", class_ = "subsection", id = "parents") as section:
@ -5658,11 +5649,7 @@ class NavWebReport(Report):
self.placemappages = self.options['placemappages'] self.placemappages = self.options['placemappages']
self.googlemap = self.options['placemappages'] self.googlemap = self.options['placemappages']
self.openstreetmap = self.options['openstreetmap'] self.openstreetmap = self.options['openstreetmap']
self.wikimapia = self.options['wikimapia']
self.familymappages = self.options['familymappages'] self.familymappages = self.options['familymappages']
self.fgooglemap = self.options['familymappages']
#self.fopenstreetmap = self.options['fopenstreetmap']
#self.fwikimapia = self.options['fwikimapia']
if self.use_home: if self.use_home:
self.index_fname = "index" self.index_fname = "index"
@ -5831,19 +5818,23 @@ class NavWebReport(Report):
Copy all of the CSS, image, and javascript files for Narrated Web Copy all of the CSS, image, and javascript files for Narrated Web
""" """
# copy behaviour style sheet # copy screen style sheet
fname = CSS["behaviour"]["filename"] if CSS[self.css]["filename"]:
self.copy_file(fname, "behaviour.css", "styles") fname = CSS[self.css]["filename"]
self.copy_file(fname, _NARRATIVESCREEN, "styles")
# copy printer style sheet
fname = CSS["Print-Default"]["filename"]
self.copy_file(fname, _NARRATIVEPRINT, "styles")
# copy ancestor tree style sheet if tree is being created? # copy ancestor tree style sheet if tree is being created?
if self.ancestortree: if self.ancestortree:
fname = CSS["ancestortree"]["filename"] fname = CSS["ancestortree"]["filename"]
self.copy_file(fname, "ancestortree.css", "styles") self.copy_file(fname, "ancestortree.css", "styles")
# copy screen style sheet # copy behaviour style sheet
if CSS[self.css]["filename"]: fname = CSS["behaviour"]["filename"]
fname = CSS[self.css]["filename"] self.copy_file(fname, "behaviour.css", "styles")
self.copy_file(fname, _NARRATIVESCREEN, "styles")
# copy Navigation Menu Layout style sheet if Blue or Visually is being used # copy Navigation Menu Layout style sheet if Blue or Visually is being used
if CSS[self.css]["navigation"]: if CSS[self.css]["navigation"]:
@ -5853,18 +5844,10 @@ class NavWebReport(Report):
fname = CSS["Navigation-Vertical"]["filename"] fname = CSS["Navigation-Vertical"]["filename"]
self.copy_file(fname, "narrative-menus.css", "styles") self.copy_file(fname, "narrative-menus.css", "styles")
# copy Mapstraction style sheet if using Place Maps # copy narrative-maps if Place or Family Map pages?
if self.placemappages or self.familymappages: if self.placemappages or self.familymappages:
fname = CSS["mapstraction"]["filename"] fname = CSS["NarrativeMaps"]["filename"]
self.copy_file(fname, "mapstraction.css", "styles") self.copy_file(fname, "narrative-maps.css", "styles")
for from_path in CSS["mapstraction"]["javascript"]:
fdir, fname = os.path.split(from_path)
self.copy_file( from_path, fname, "mapstraction" )
# copy printer style sheet
fname = CSS["Print-Default"]["filename"]
self.copy_file(fname, _NARRATIVEPRINT, "styles")
imgs = [] imgs = []
@ -6705,21 +6688,21 @@ class NavWebOptions(MenuReportOptions):
category_name = _("Place Maps") category_name = _("Place Maps")
addopt = partial(menu.add_option, category_name) addopt = partial(menu.add_option, category_name)
placemappages = BooleanOption(_("Include Place map on Place Pages (Google maps)"), False) self.__placemappages = BooleanOption(_("Include Place map on Place Pages (Google maps)"), False)
placemappages.set_help(_("Whether to include a Google map on the Place Pages, " self.__placemappages.set_help(_("Whether to include a Google map on the Place Pages, "
"where Latitude/ Longitude are available.")) "where Latitude/ Longitude are available."))
addopt( "placemappages", placemappages ) self.__placemappages.connect("value-changed", self.__placemaps_changed)
addopt( "placemappages", self.__placemappages)
openstreetmap = BooleanOption(_("Include Place map on Place Pages (OpenStreetMap)"), False) self.__openstreetmap = BooleanOption(_("Include Place map on Place Pages (OpenStreetMap)"), False)
openstreetmap.set_help(_("Whether to include a OpenStreet map on the Place Pages, " self.__openstreetmap.set_help(_("Whether to include a OpenStreet map on the Place Pages, "
"where Latitude/ Longitude are available.")) "where Latitude/ Longitude are available."))
addopt( "openstreetmap", openstreetmap ) self.__openstreetmap.connect("value-changed", self.__openstreetmap_changed)
addopt("openstreetmap", self.__openstreetmap)
wikimapia = BooleanOption(_("Include Place map on Place Pages (Wikimapia)"), False)
wikimapia.set_help(_("Whether to include a Wikimapia map on the Place Pages, "
"where Latitude/ Longitude are available."))
addopt( "wikimapia", wikimapia )
self.__placemaps_changed()
self.__openstreetmap_changed()
familymappages = BooleanOption(_("Include Individual Page Map with " familymappages = BooleanOption(_("Include Individual Page Map with "
"all places shown on map (Google Maps)"), False) "all places shown on map (Google Maps)"), False)
familymappages.set_help(_("Whether or not to add an individual Google map " familymappages.set_help(_("Whether or not to add an individual Google map "
@ -6728,22 +6711,6 @@ class NavWebOptions(MenuReportOptions):
"traveled around the country.")) "traveled around the country."))
addopt( "familymappages", familymappages ) addopt( "familymappages", familymappages )
#fopenstreetmap = BooleanOption(_("Include Individual Page Map with "
#"all places shown on map (OpenStreetMap)"), False)
#fopenstreetmap.set_help(_("Whether or not to add an individual OpenStreet map "
#"showing all the places on this page. "
#"This will allow you to see how your family "
#"traveled around the country."))
#addopt( "fopenstreetmap", fopenstreetmap )
#fwikimapia = BooleanOption(_("Include Individual Page Map with "
#"all places shown on map (Wikimapia)"), False)
#fwikimapia.set_help(_("Whether or not to add an individual Wikimapia map "
#"showing all the places on this page. "
#"This will allow you to see how your family "
#"traveled around the country."))
#addopt( "fwikimapia", fwikimapia )
def __archive_changed(self): def __archive_changed(self):
""" """
@ -6831,6 +6798,20 @@ class NavWebOptions(MenuReportOptions):
self.__down_fname2.set_available(False) self.__down_fname2.set_available(False)
self.__dl_descr2.set_available(False) self.__dl_descr2.set_available(False)
def __placemaps_changed(self):
""" Handles changing nature of google Maps"""
if self.__placemappages.get_value():
self.__openstreetmap.set_available(False)
else:
self.__openstreetmap.set_available(True)
def __openstreetmap_changed(self):
"""Handles changing nature of openstreetmaps"""
if self.__openstreetmap.get_value():
self.__placemappages.set_available(False)
else:
self.__placemappages.set_available(True)
# FIXME. Why do we need our own sorting? Why not use Sort.Sort? # FIXME. Why do we need our own sorting? Why not use Sort.Sort?
def sort_people(db, handle_list): def sort_people(db, handle_list):
sname_sub = defaultdict(list) sname_sub = defaultdict(list)

View File

@ -69,45 +69,3 @@ div#middlesection {
float: center; float: center;
overflow-y: hidden; overflow-y: hidden;
} }
/* Y Map Sizes
------------------------------------------------- */
div#largeYMap {
width: 1400px;
margin: 1%;
}
div#middleYMap {
width: 1000px;
margin: 2%;
}
div#smallYMap {
width: 800px;
margin: 0px 8% 10px 9%;
}
div#YMap {
width: 800px;
margin: 0% 8% 10px 9%;
}
/* X Map Sizes
------------------------------------------------- */
div#largeXMap {
height: 1400px;
}
div#middleXMap {
height: 1200px;
}
div#smallXMap {
height: 800px;
}
div#XMap {
height: 800px;
}
/* map_canvas
------------------------------------------------- */
div#map_canvas {
height: 100%;
width: 100%;
border: double 4px #000;
}

View File

@ -106,13 +106,9 @@ def load_on_reg(dbstate, uistate, plugin):
["behaviour", 0, "Behaviour", ["behaviour", 0, "Behaviour",
path_css('behaviour.css'), None, [], []], path_css('behaviour.css'), None, [], []],
# mapstraction style sheet for NarrativeWeb place maps # NarrativeMpasstyle sheet for NarrativeWeb place maps
["mapstraction", 0, "", ["NarrativeMaps", 0, "",
path_css("narrative-maps.css"), None, [], path_css("narrative-maps.css"), None, [], []],
[path_js("mapstraction", "mxn.core.js"),
path_js("mapstraction", "mxn.googlev3.core.js"),
path_js("mapstraction", "mxn.js"),
path_js("mapstraction", "mxn.openlayers.core.js")] ],
# default style sheet in the options # default style sheet in the options
["default", 0, _("Basic-Ash"), ["default", 0, _("Basic-Ash"),