Fixed errors created by my last commit# 18480.

svn: r18484
This commit is contained in:
Rob G. Healey 2011-11-22 11:18:07 +00:00
parent 7b2ea14225
commit a52ab113f7
2 changed files with 85 additions and 43 deletions

View File

@ -4874,22 +4874,27 @@ class IndividualPage(BasePage):
# create the array, if there are more than one set of coordinates to be displayed? # create the array, if there are more than one set of coordinates to be displayed?
if number_markers > 1: if number_markers > 1:
if self.googleopts == "FamilyLinks":
tracelife = """ tracelife = """
var tracelife = [""" var tracelife = ["""
# place titles Array for place maps...
titleArray = """ titleArray = """
var titleArray = [""" var titleArray = ["""
for index in xrange(0, (number_markers - 1)): for index in xrange(0, (number_markers - 1)):
dataline = place_lat_long[index] dataline = place_lat_long[index]
latitude, longitude, placetitle = dateline[0], dataline[1], dataline[2] latitude, longitude, placetitle = dataline[0], dataline[1], dataline[2]
tracelife += """ new google.maps.LatLng(%s, %s),""" % (latitude, longitude) tracelife += """
titleArray += """ ['%s'],""" % placetitle new google.maps.LatLng(%s, %s),""" % (latitude, longitude)
titleArray += """'%s',""" % placetitle
dataline = place_lat_long[-1] dataline = place_lat_long[-1]
latitude, longitude, placetitle = dataline[0], dataline[1], dataline[2] latitude, longitude, placetitle = dataline[0], dataline[1], dataline[2]
tracelife += """ new google.maps.LatLng(%s, %s) ];""" % (latitude, longitude) tracelife += """
titleArray += """ ['%s'] ];""" % placetitle new google.maps.LatLng(%s, %s) ];""" % (latitude, longitude)
titleArray += """
'%s' ];""" % placetitle
of = self.report.create_file(person.get_handle(), "maps") of = self.report.create_file(person.get_handle(), "maps")
self.up = True self.up = True
@ -4914,18 +4919,19 @@ class IndividualPage(BasePage):
src ="http://www.openlayers.org/api/OpenLayers.js", inline =True) src ="http://www.openlayers.org/api/OpenLayers.js", inline =True)
# begin inline javascript code # begin inline javascript code
# because jsc is a string, it does NOT have to properly indented # because jsc is a docstring, it does NOT have to properly indented
with Html("script", type ="text/javascript", indent =False) as jsc: with Html("script", type ="text/javascript", indent =False) as jsc:
# Google Maps add their javascript inside of the head element...
if self.mapservice == "Google": if self.mapservice == "Google":
head += jsc head += jsc
# 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:
data = place_lat_long[0] dataline = place_lat_long[0]
jsc += google_jsc % (data[0], data[1]) latitude, longitude = dataline[0], dataline[1]
jsc += google_jsc % (latitude, longitude)
# Google Maps add their javascript inside of the head element...
else: else:
if self.googleopts == "FamilyLinks": if self.googleopts == "FamilyLinks":
jsc += """ jsc += """
@ -4941,64 +4947,89 @@ class IndividualPage(BasePage):
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var flightPath = new google.maps.Polyline({ var flightPath = new google.maps.Polyline({
path: lifeHistory, path: %s,
strokeColor: "#FF0000", strokeColor: "#FF0000",
strokeOpacity: 1.0, strokeOpacity: 1.0,
strokeWeight: 2 strokeWeight: 2
}); });
flightPath.setMap(map); flightPath.setMap(map);
}""" % (latitude, longitude) }""" % (midX_, midY_, zoomlevel, lifetrace)
# Google Maps Markers only... # Google Maps Markers only...
elif self.googleopts == "Markers": elif self.googleopts == "Markers":
if (not midX_ and not midY_): if (not midX_ and not midY_):
midX_, midY_ = conv_lat_lon(place_lat_long[0][0], place_lat_long[0][1], "D.D8") midX_, midY_ = conv_lat_lon(place_lat_long[0][0], place_lat_long[0][1], "D.D8")
jsc += """ jsc += """
//<![CDATA[ //<![CDATA[
var centre = new google.maps.LatLng(%s, %s); var centre = new google.maps.LatLng(%s, %s);""" % (midX_, midY_)
var gpsCoords = [""" % (midX_, midY_) jsc += """
var myCoordinates = ["""
for index in xrange(0, (number_markers - 1)): for index in xrange(0, (number_markers - 1)):
latitude, longitude = place_lat_long[index][0], place_lat_long[index][1] dataline = place_lat_long[index]
latitude, longitude, placetitle = dataline[0], dataline[1], dataline[2]
jsc += """ new google.maps.LatLng(%s, %s),""" % (latitude, longitude) jsc += """ new google.maps.LatLng(%s, %s),""" % (latitude, longitude)
latitude, longitude = place_lat_long[-1][0], place_lat_long[-1][1]
dataline = place_lat_long[-1]
latitude, longitude, placetitle = dataline[0], dataline[1], dataline[2]
jsc += """ new google.maps.LatLng(%s, %s) jsc += """ new google.maps.LatLng(%s, %s)
]; ];""" % (latitude, longitude)
jsc += """
var markers = []; var markers = [];
var iterator = 0; var iterator = 0;
var map; var map;
function initialize() { function initialize() {
var mapOptions = { var mapOptions = {
scrollwheel: false,
scaleControl: false,
backgroundColor: '#FFFFFF',
zoom: %d, zoom: %d,
mapTypeId: google.maps.MapTypeId.ROADMAP, center: centre,
center: centre mapTypeId: google.maps.MapTypeId.ROADMAP
} }
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
} }
function drop() {
for (var i = 0; i < gpsCoords.length; i++) { function drop() {
for (var i = 0; i < myCoordinates.length; i++) {
setTimeout(function() { setTimeout(function() {
addMarker(); addMarkers();
}, i * 1000); }, i * 1000);
} }
} }
function addMarker() {
function addMarkers() {
markers.push(new google.maps.Marker({ markers.push(new google.maps.Marker({
position: gpsCoords[iterator], position: myCoordinates[iterator],
map: map, map: map,
draggable: true, draggable: true,
animation: google.maps.Animation.DROP animation: google.maps.Animation.DROP
})); }));
iterator++; iterator++;
} }
//]]>""" % (latitude, longitude, zoomlevel) //]]>""" % zoomlevel
# there is no need to add an ending "</script>", # there is no need to add an ending "</script>",
# as it will be added automatically by libhtml()! # as it will be added automatically by libhtml()!
dont = """
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
function setMarkers(map, locations) {
var bounds = new google.maps.LatLngBounds();
for (var i = 0; i < locations.length; i++) {
var coordinates = locations[i];
var myLatLng = new google.maps.LatLng(coordinates[1], coordinates[2]);
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: coordinates[0]
});
bounds.extend(locations[i]);
map.fitBounds(bounds);
}"""
with Html("div", class_ ="content", id ="FamilyMapDetail") as mapbackground: with Html("div", class_ ="content", id ="FamilyMapDetail") as mapbackground:
body += mapbackground body += mapbackground

View File

@ -21,15 +21,26 @@
# $Id$ # $Id$
# #
###################################################### */ ###################################################### */
body#FamilyMap {
div#map_canvas { background-color: #000;
margin: 0 auto; margin-left: 7px;
padding: 0px 0px 10px 10px; margin-right: 7px;
border: solid 4px #000;
width: 965px; width: 965px;
}
div#map_canvas {
margin-left: 10px;
margin-right: 10px;
border: solid 4px #000;
width: 931px;
height: 800px; height: 800px;
} }
button#drop { button#drop {
background-color: purple;
color: #FFF;
font: bold .8em sans-serif;
padding: 10px; padding: 10px;
border: solid 1px #000; margin-top: 0px;
margin-bottom: 10px;
margin-left: 10px;
border: solid 2px green;
} }