NarrayiveWeb: More tweaking of _create_family_map().

svn: r15690
This commit is contained in:
Rob G. Healey 2010-08-09 06:56:47 +00:00
parent 791ab064f8
commit b0060b7542
2 changed files with 55 additions and 41 deletions

View File

@ -85,6 +85,10 @@ div#smallYMap {
width: 800px; width: 800px;
margin: 0% 8% 0% 9%; margin: 0% 8% 0% 9%;
} }
div#YMap {
width: 800px;
margin: 0% 8% 0% 9%;
}
/* X Map Sizes /* X Map Sizes
------------------------------------------------- */ ------------------------------------------------- */
@ -97,6 +101,9 @@ div#middleXMap {
div#smallXMap { div#smallXMap {
height: 800px; height: 800px;
} }
div#XMap {
height: 800px;
}
/* Family GoogleV3 /* Family GoogleV3
------------------------------------------------- */ ------------------------------------------------- */

View File

@ -3889,11 +3889,11 @@ class IndividualPage(BasePage):
# and close the file # and close the file
self.XHTMLWriter(indivdetpage, of) self.XHTMLWriter(indivdetpage, of)
def _create_family_map(self, person_handle): def _create_family_map(self, person):
""" """
creates individual family map page creates individual family map page
@param: person_handle -- used for naming the map file as self.html_dir/maps/ ... @param: person -- person from database
""" """
# fields in place_lat_long = latitude, longitude, place name, and handle # fields in place_lat_long = latitude, longitude, place name, and handle
@ -3903,14 +3903,9 @@ class IndividualPage(BasePage):
if not place_lat_long: if not place_lat_long:
return return
MinX = "0.00000001" MinX, MaxX = "0.00000001", "0.00000001"
MaxX = "0.00000001" MinY, MaxY = "0.00000001", "0.00000001"
MinY = "0.00000001" XCoordinates, YCoordinates = [], []
MaxY = "0.00000001"
spanX = 0
spanY = 0
XCoordinates = []
YCoordinates = []
number_markers = len(place_lat_long) number_markers = len(place_lat_long)
if number_markers > 3: if number_markers > 3:
@ -3920,27 +3915,32 @@ class IndividualPage(BasePage):
YCoordinates.append(long) YCoordinates.append(long)
XCoordinates.sort() XCoordinates.sort()
MinX = XCoordinates[0] MinX = XCoordinates[0]
MaxX = XCoordinates[-1] MaxX = XCoordinates[-1]
spanX = int( Decimal( MaxX ) - Decimal( MinX ) )
YCoordinates.sort() YCoordinates.sort()
MinY = YCoordinates[0] MinY = YCoordinates[0]
MaxY = YCoordinates[-1] MaxY = YCoordinates[-1]
spanY = int( Decimal( MaxY ) - Decimal( MinY ) )
spanY = int( Decimal( MaxY ) - Decimal( MinY ) )
spanX = int( Decimal( MaxX ) - Decimal( MinX ) )
smallset = [num for num in range(-17, 0)] # define smallset of Y and X span for span variables
for num in range(0, 17): smallset = [num for num in xrange(-17, 0)]
smallset.append(num) smallset += [num for num in xrange(0, 18)]
middleset = [num for num in range(-41, -17)] # define middleset of Y and X span for span variables
for num in range(17, 41): middleset = [num for num in xrange(-41, -17)]
middleset.append(num) middleset += [num for num in xrange(18, 42)]
# define middleset of Y and X span for span variables
largeset = [num for num in xrange(-81, -41)]
largeset += [num for num in xrange(42, 82)]
# sort place_lat_long based on chronological date order # sort place_lat_long based on chronological date 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, 2, 0))
of = self.report.create_file(person_handle, "maps") of = self.report.create_file(person.handle, "maps")
self.up = True self.up = True
familymappage, head, body = self.write_header(_("Family Map")) familymappage, head, body = self.write_header(_("Family Map"))
@ -3951,23 +3951,25 @@ class IndividualPage(BasePage):
# add googlev3 specific javascript code # add googlev3 specific javascript code
head += Html("script", type = "text/javascript", head += Html("script", type = "text/javascript",
src = "http://maps.google.com/maps/api/js?sensor=true", inline = True) src = "http://maps.google.com/maps/api/js?sensor=false", inline = True)
# add mapstraction javascript code # add mapstraction javascript code
fname = "/".join(["mapstraction", "mxn.js?(googlev3)"]) fname = "/".join(["mapstraction", "mxn.js?(googlev3)"])
url = self.report.build_url_fname(fname, None, self.up) url = self.report.build_url_fname(fname, None, self.up)
head += Html("script", src = url, inline = True) head += Html("script", src = url, type = "text/javascript", inline = True)
# set map dimensions based on span of Y Coordinates # set map dimensions based on span of Y Coordinates
ymap = ""
if spanY in smallset: if spanY in smallset:
map_size = "smallYMap" ymap = "small"
elif spanY in middleset: elif spanY in middleset:
map_size = "middleYMaap" ymap = "middle"
else: elif spanY in largeset:
map_size = "largeYMap" ymap = "large"
ymap += "YMap"
# begin familymap division # begin familymap division
with Html("div", class_ = "content", id = map_size) as mapbody: with Html("div", class_ = "content", id = ymap) as mapbody:
body += mapbody body += mapbody
# page message # page message
@ -3979,15 +3981,17 @@ class IndividualPage(BasePage):
"will display its place title.") "will display its place title.")
mapbody += Html("p", msg, id = "description") mapbody += Html("p", msg, id = "description")
xmap = ""
if spanX in smallset: if spanX in smallset:
map_size = "smallXMap" xmap = "small"
elif spanX in middleset: elif spanX in middleset:
map_size = "middleXMaap" xmap = "middle"
else: elif spanX in largeset:
map_size = "largeXMap" xmap = "large"
xmap += "XMap"
# begin middle section division # begin middle section division
with Html("div", id = map_size) as middlesection: with Html("div", id = xmap) as middlesection:
mapbody += middlesection mapbody += middlesection
# begin inline javascript code # begin inline javascript code
@ -4019,6 +4023,7 @@ class IndividualPage(BasePage):
jsc += """ jsc += """
}""" }"""
# if the span is larger than +- 42 which is the span of four(4) states in the USA
if spanY not in smallset and spanY not in middleset: if spanY not in smallset and spanY not in middleset:
# set southWest and northEast boundaries as spanY is greater than 20 # set southWest and northEast boundaries as spanY is greater than 20
@ -4037,19 +4042,21 @@ class IndividualPage(BasePage):
function add_markers(latitude, longitude, title) { function add_markers(latitude, longitude, title) {
var latlon = new mxn.LatLonPoint(latitude, longitude); var latlon = new mxn.LatLonPoint(latitude, longitude);
var marker = new mxn.Marker(latlon); var marker = new mxn.Marker(latlon);
marker.setInfoBubble('<div id="geo-info">' + title + '</div>'); marker.setInfoBubble('<div id="geo-info">' + title + '</div>');
map.addMarker(marker, true);""" map.addMarker(marker, true);"""
# set zoomlevel for size of map
if spanY in smallset: if spanY in smallset:
zoomlevel = 6 zoomlevel = 7
elif spanY in middleset: elif spanY in middleset:
zoomlevel = 4 zoomlevel = 4
else: elif spanY in largeset:
zoomlevel = 1 zoomlevel = 4
else:
zoomlevel = 1
jsc += """ jsc += """
map.setCenterAndZoom(latlon, %d); map.setCenterAndZoom(latlon, %d);
@ -4058,7 +4065,7 @@ class IndividualPage(BasePage):
# there is no need to add an ending "</script>", # there is no need to add an ending "</script>",
# as it will be added automatically! # as it will be added automatically!
# here is where the map is held in the CSS # here is where the map is held in the CSS/ Page
middlesection += Html("div", id = "familygooglev3", inline = True) middlesection += Html("div", id = "familygooglev3", inline = True)
# add fullclear for proper styling # add fullclear for proper styling
@ -4074,7 +4081,7 @@ class IndividualPage(BasePage):
# 0 = latitude, 1 = longitude, 2 = place title, 3 = handle, 4 = date # 0 = latitude, 1 = longitude, 2 = place title, 3 = handle, 4 = date
for (lat, long, pname, handle, date) in place_lat_long: for (lat, long, pname, handle, date) in place_lat_long:
list = Html("li", self.place_link(handle, pname, up = True)) list = Html("li", self.place_link(handle, pname, up = self.up))
ordered += list ordered += list
if date: if date:
@ -4102,7 +4109,7 @@ class IndividualPage(BasePage):
""" """
# create family map page # create family map page
self._create_family_map(person.handle) self._create_family_map(person)
# begin family map division plus section title # begin family map division plus section title
with Html("div", class_ = "subsection", id = "familymap") as familymap: with Html("div", class_ = "subsection", id = "familymap") as familymap: