The bugtracker for this one has a lot of others attached to it. Bug#5026, #4029, #2313, and #5103. Benny has given permission for me to add this to NarrativeWeb so that we could get rid of the mapstraction/mxn javascript files...
svn: r17994
This commit is contained in:
parent
d37abb43df
commit
2dbf98feee
@ -116,3 +116,58 @@ _COPY_OPTIONS = [
|
|||||||
|
|
||||||
_('No copyright notice'),
|
_('No copyright notice'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# NarrativeWeb javascript code for PlacePage's "Google Maps"...
|
||||||
|
google_jsc = """
|
||||||
|
var myLatlng = new google.maps.LatLng(%s, %s);
|
||||||
|
|
||||||
|
function initialize() {
|
||||||
|
var mapOptions = {
|
||||||
|
zoom: 13,
|
||||||
|
mapTypeId: google.maps.MapTypeId.ROADMAP,
|
||||||
|
center: myLatlng
|
||||||
|
};
|
||||||
|
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
|
||||||
|
|
||||||
|
var marker = new google.maps.Marker({
|
||||||
|
map: map,
|
||||||
|
draggable: true,
|
||||||
|
animation: google.maps.Animation.DROP,
|
||||||
|
position: myLatlng
|
||||||
|
});
|
||||||
|
google.maps.event.addListener(marker, 'click', toggleBounce);
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleBounce() {
|
||||||
|
if (marker.getAnimation() != null) {
|
||||||
|
marker.setAnimation(null);
|
||||||
|
} else {
|
||||||
|
marker.setAnimation(google.maps.Animation.BOUNCE);
|
||||||
|
}
|
||||||
|
}"""
|
||||||
|
|
||||||
|
# NarrativeWeb javascript code for PlacePage's "Open Street Map"...
|
||||||
|
openstreet_jsc = """
|
||||||
|
OpenLayers.Lang.setCode("%s");
|
||||||
|
|
||||||
|
map = new OpenLayers.Map("map_canvas");
|
||||||
|
var osm = new OpenLayers.Layer.OSM()
|
||||||
|
map.addLayer(osm);
|
||||||
|
|
||||||
|
var lonLat = new OpenLayers.LonLat(%s, %s)
|
||||||
|
.transform(
|
||||||
|
new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
|
||||||
|
map.getProjectionObject() // to Spherical Mercator Projection
|
||||||
|
);
|
||||||
|
var zoom =16;
|
||||||
|
map.setCenter(lonLat, zoom);
|
||||||
|
|
||||||
|
var markers = new OpenLayers.Layer.Markers("Markers");
|
||||||
|
markers.addMarker(new OpenLayers.Marker(lonLat));
|
||||||
|
map.addLayer(markers);
|
||||||
|
|
||||||
|
// add overview control
|
||||||
|
map.addControl(new OpenLayers.Control.OverviewMap());
|
||||||
|
|
||||||
|
// add a layer switcher
|
||||||
|
map.addControl(new OpenLayers.Control.LayerSwitcher());"""
|
||||||
|
@ -100,6 +100,9 @@ from DateHandler import displayer as _dd
|
|||||||
from gen.proxy import PrivateProxyDb, LivingProxyDb
|
from gen.proxy import PrivateProxyDb, LivingProxyDb
|
||||||
from libhtmlconst import _CHARACTER_SETS, _CC, _COPY_OPTIONS
|
from libhtmlconst import _CHARACTER_SETS, _CC, _COPY_OPTIONS
|
||||||
|
|
||||||
|
# import for Place Map Pages...
|
||||||
|
from libhtmlconst import openstreet_jsc, google_jsc
|
||||||
|
|
||||||
# import HTML Class from
|
# import HTML Class from
|
||||||
# src/plugins/lib/libhtml.py
|
# src/plugins/lib/libhtml.py
|
||||||
from libhtml import Html
|
from libhtml import Html
|
||||||
@ -2528,8 +2531,7 @@ class PlacePage(BasePage):
|
|||||||
placepage, head, body = self.write_header(_("Places"))
|
placepage, head, body = self.write_header(_("Places"))
|
||||||
|
|
||||||
self.placemappages = self.report.options['placemappages']
|
self.placemappages = self.report.options['placemappages']
|
||||||
self.googlemap = self.report.options['placemappages']
|
self.mapservice = self.report.options['mapservice']
|
||||||
self.openstreetmap = self.report.options['openstreetmap']
|
|
||||||
|
|
||||||
# begin PlaceDetail Division
|
# begin PlaceDetail Division
|
||||||
with Html("div", class_ = "content", id = "PlaceDetail") as placedetail:
|
with Html("div", class_ = "content", id = "PlaceDetail") as placedetail:
|
||||||
@ -2576,84 +2578,47 @@ 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) and
|
if self.placemappages:
|
||||||
(place and (place.lat and place.long) ) ):
|
if (place and (place.lat and place.long)):
|
||||||
|
|
||||||
# get reallatitude and reallongitude from place
|
# get reallatitude and reallongitude from place
|
||||||
latitude, longitude = conv_lat_lon( place.lat,
|
latitude, longitude = conv_lat_lon(place.lat, place.long, "D.D8")
|
||||||
place.long,
|
|
||||||
"D.D8")
|
|
||||||
|
|
||||||
# add narrative-maps CSS...
|
# add narrative-maps CSS...
|
||||||
fname = "/".join(["styles", "narrative-maps.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 MapService specific javascript code
|
||||||
if self.googlemap:
|
if self.mapservice == "Google":
|
||||||
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)
|
||||||
|
else:
|
||||||
# Place Map division
|
head += Html("script", type ="text/javascript",
|
||||||
with Html("div", id = "mapstraction") as mapstraction:
|
src ="http://www.openlayers.org/api/OpenLayers.js", inline =True)
|
||||||
placedetail += mapstraction
|
|
||||||
|
|
||||||
# section title
|
# section title
|
||||||
mapstraction += Html("h4", _("Place Map"), inline = True)
|
placedetail += Html("h4", _("Place Map"), inline =True)
|
||||||
|
|
||||||
# begin middle division
|
# begin map_canvas division
|
||||||
with Html("div", id = "middle") as middle:
|
with Html("div", id ="map_canvas") as canvas:
|
||||||
mapstraction += middle
|
placedetail += canvas
|
||||||
|
|
||||||
if self.openstreetmap:
|
|
||||||
url = 'http://www.openstreetmap.com/?lat=%s&lon=%s&zoom=11&layers=M' % (
|
|
||||||
latitude, longitude)
|
|
||||||
middle += Html("object", data = url, inline = True)
|
|
||||||
|
|
||||||
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 docstring, it does NOT have to be properly indented
|
||||||
with Html("script", type = "text/javascript") as jsc:
|
with Html("script", type = "text/javascript") as jsc:
|
||||||
head += jsc
|
head += jsc
|
||||||
|
|
||||||
jsc += """
|
if self.mapservice == "Google":
|
||||||
var myLatlng = new google.maps.LatLng(%s, %s);""" % (latitude, longitude)
|
jsc += google_jsc % (latitude, longitude)
|
||||||
|
else:
|
||||||
jsc += """
|
jsc += openstreet_jsc % (Utils.xml_lang()[3:5].lower(),
|
||||||
var marker;
|
longitude, latitude)
|
||||||
var map;
|
|
||||||
|
|
||||||
function initialize() {
|
|
||||||
var mapOptions = {
|
|
||||||
zoom: 13,
|
|
||||||
mapTypeId: google.maps.MapTypeId.ROADMAP,
|
|
||||||
center: myLatlng
|
|
||||||
};
|
|
||||||
map = new google.maps.Map(document.getElementById("middle"), mapOptions);
|
|
||||||
|
|
||||||
marker = new google.maps.Marker({
|
|
||||||
map: map,
|
|
||||||
draggable: true,
|
|
||||||
animation: google.maps.Animation.DROP,
|
|
||||||
position: myLatlng
|
|
||||||
});
|
|
||||||
|
|
||||||
google.maps.event.addListener(marker, 'click', toggleBounce);
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleBounce() {
|
|
||||||
|
|
||||||
if (marker.getAnimation() != null) {
|
|
||||||
marker.setAnimation(null);
|
|
||||||
} else {
|
|
||||||
marker.setAnimation(google.maps.Animation.BOUNCE);
|
|
||||||
}
|
|
||||||
}"""
|
|
||||||
# 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!
|
||||||
|
|
||||||
# add fullclear for proper styling
|
# add fullclear for proper styling
|
||||||
middle += fullclear
|
canvas += fullclear
|
||||||
|
|
||||||
# add javascript function call to body element
|
# add javascript function call to body element
|
||||||
body.attr ='onload ="initialize();" '
|
body.attr ='onload ="initialize();" '
|
||||||
@ -4033,58 +3998,72 @@ 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):
|
def __create_family_map(self, person):
|
||||||
"""
|
"""
|
||||||
creates individual family map page
|
creates individual family map page
|
||||||
|
|
||||||
@param: person -- person from database
|
@param: person -- person from database
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# fields in place_lat_long = latitude, longitude, place name, and handle
|
# fields in place_lat_long = latitude, longitude, placename, handle, and date of event
|
||||||
global place_lat_long
|
global place_lat_long
|
||||||
|
|
||||||
# if there is no latitude/ longitude data, then return
|
# if there is no latitude/ longitude data, then return?
|
||||||
if not place_lat_long:
|
if not place_lat_long:
|
||||||
return
|
return
|
||||||
|
|
||||||
minX, maxX = "0.00000001", "0.00000001"
|
self.familymappages = self.report.options['familymappages']
|
||||||
minY, maxY = "0.00000001", "0.00000001"
|
self.mapservice = self.report.options['mapservice']
|
||||||
XCoordinates, YCoordinates = [], []
|
self.googleopts = self.report.options['googleopts']
|
||||||
|
|
||||||
|
minx, maxx = Decimal("0.00000001"), Decimal("0.00000001")
|
||||||
|
miny, maxy = Decimal("0.00000001"), Decimal("0.00000001")
|
||||||
|
xwidth, yheight = [], []
|
||||||
|
midX_, midY_, spanx, spany = [None]*4
|
||||||
|
|
||||||
number_markers = len(place_lat_long)
|
number_markers = len(place_lat_long)
|
||||||
|
if number_markers > 1:
|
||||||
|
for (lat, long, p, h, d) in place_lat_long:
|
||||||
|
xwidth.append(lat)
|
||||||
|
yheight.append(long)
|
||||||
|
xwidth.sort()
|
||||||
|
yheight.sort()
|
||||||
|
|
||||||
for (lat, long, pname, handle, date) in place_lat_long:
|
minx = xwidth[0] if xwidth[0] else minx
|
||||||
XCoordinates.append(lat)
|
maxx = xwidth[-1] if xwidth[-1] else maxx
|
||||||
YCoordinates.append(long)
|
minx, maxx = Decimal(minx), Decimal(maxx)
|
||||||
|
midX_ = str( Decimal( (minx + maxx) /2) )
|
||||||
|
|
||||||
XCoordinates.sort()
|
miny = yheight[0] if yheight[0] else miny
|
||||||
minX = XCoordinates[0] if XCoordinates[0] is not None else minX
|
maxy = yheight[-1] if yheight[-1] else maxy
|
||||||
maxX = XCoordinates[-1] if XCoordinates[-1] is not None else maxX
|
miny, maxy = Decimal(miny), Decimal(maxy)
|
||||||
|
midY_ = str( Decimal( (miny + maxy) /2) )
|
||||||
|
|
||||||
YCoordinates.sort()
|
midX_, midY_ = conv_lat_lon(midX_, midY_, "D.D8")
|
||||||
minY = YCoordinates[0] if YCoordinates[0] is not None else minY
|
|
||||||
maxY = YCoordinates[-1] if YCoordinates[-1] is not None else maxY
|
|
||||||
|
|
||||||
try:
|
# get the integer span of latitude and longitude
|
||||||
spanY = int( Decimal( maxY ) - Decimal( minY ) )
|
spanx = int(maxx - minx)
|
||||||
except:
|
spany = int(maxy - miny)
|
||||||
spanY = 0
|
|
||||||
try:
|
|
||||||
spanX = int( Decimal( maxX ) - Decimal( minX ) )
|
|
||||||
except:
|
|
||||||
spanX = 0
|
|
||||||
|
|
||||||
# define smallset of Y and X span for span variables
|
# set zoom level based on span of Longitude?
|
||||||
smallset = set(xrange(-17,18))
|
tinyset = [value for value in (-3, -2, -1, 0, 1, 2, 3)]
|
||||||
|
smallset = [value for value in (-4, -5, -6, -7, 4, 5, 6, 7)]
|
||||||
|
middleset = [value for value in (-8, -9, -10, -11, 8, 9, 10, 11)]
|
||||||
|
largeset = [value for value in (-11, -12, -13, -14, -15, -16, -17, 11, 12, 13, 14, 15, 16, 17)]
|
||||||
|
|
||||||
# define middleset of Y and X span for span variables
|
if spany in tinyset:
|
||||||
middleset = set(xrange(-41, 42)) - smallset
|
zoomlevel = 13
|
||||||
|
elif spany in smallset:
|
||||||
|
zoomlevel = 6
|
||||||
|
elif spany in middleset:
|
||||||
|
zoomlevel = 5
|
||||||
|
elif spany in largeset:
|
||||||
|
zoomlevel = 4
|
||||||
|
else:
|
||||||
|
zoomlevel = 3
|
||||||
|
|
||||||
# define largeset of Y and X span for span variables
|
# sort place_lat_long based on latitude and longitude order...
|
||||||
largeset = set(xrange(-81, 82)) - middleset - smallset
|
place_lat_long.sort()
|
||||||
|
|
||||||
# sort place_lat_long based on chronological date order
|
|
||||||
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
|
||||||
@ -4095,136 +4074,194 @@ class IndividualPage(BasePage):
|
|||||||
# if active
|
# if active
|
||||||
# call_(report, up, head)
|
# call_(report, up, head)
|
||||||
|
|
||||||
# add narrative-maps.css
|
# add narrative-maps style sheet
|
||||||
fname = "/".join(["styles", "narrative-maps.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 MapService specific javascript code
|
||||||
|
if self.mapservice == "Google":
|
||||||
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)
|
||||||
|
|
||||||
# add mapstraction javascript code
|
else:
|
||||||
fname = "/".join(["mapstraction", "mxn.js?(googlev3)"])
|
head += Html("script", type ="text/javascript",
|
||||||
url = self.report.build_url_fname(fname, None, self.up)
|
src ="http://www.openlayers.org/api/OpenLayers.js", inline =True)
|
||||||
head += Html("script", src = url, type = "text/javascript", inline = True)
|
|
||||||
|
|
||||||
# set map dimensions based on span of Y Coordinates
|
# begin inline javascript code
|
||||||
ymap = ""
|
# because jsc is a string, it does NOT have to properly indented
|
||||||
if spanY in smallset:
|
with Html("script", type ="text/javascript", indent =False) as jsc:
|
||||||
ymap = "small"
|
|
||||||
elif spanY in middleset:
|
if self.mapservice == "Google":
|
||||||
ymap = "middle"
|
head += jsc
|
||||||
elif spanY in largeset:
|
|
||||||
ymap = "large"
|
# if the number of places is only 1, then use code from imported javascript?
|
||||||
ymap += "YMap"
|
if number_markers == 1:
|
||||||
|
data = place_lat_long[0]
|
||||||
|
jsc += google_jsc % ( data[0], data[1] )
|
||||||
|
|
||||||
|
# Google Maps add their javascript inside of the head element...
|
||||||
|
else:
|
||||||
|
if self.googleopts == "FamilyLinks":
|
||||||
|
jsc += """
|
||||||
|
function initialize() {
|
||||||
|
var myLatLng = new google.maps.LatLng(%s, %s);
|
||||||
|
|
||||||
|
var myOptions = {
|
||||||
|
zoom: %d,
|
||||||
|
center: myLatLng,
|
||||||
|
mapTypeId: google.maps.MapTypeId.ROADMAP
|
||||||
|
};
|
||||||
|
|
||||||
|
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
|
||||||
|
|
||||||
|
var lifeHistory = [""" % (midX_, midY_, zoomlevel)
|
||||||
|
for index in xrange(0, (number_markers - 1)):
|
||||||
|
data = place_lat_long[index]
|
||||||
|
latitude, longitude = conv_lat_lon(data[0], data[1], "D.D8")
|
||||||
|
jsc += """ new google.maps.LatLng(%s, %s),""" % (latitude, longitude)
|
||||||
|
data = place_lat_long[-1]
|
||||||
|
latitude, longitude = conv_lat_lon(data[0], data[1], "D.D8")
|
||||||
|
jsc += """ new google.maps.LatLng(%s, %s) ];
|
||||||
|
|
||||||
|
var flightPath = new google.maps.Polyline({
|
||||||
|
path: lifeHistory,
|
||||||
|
strokeColor: "#FF0000",
|
||||||
|
strokeOpacity: 1.0,
|
||||||
|
strokeWeight: 2
|
||||||
|
});
|
||||||
|
|
||||||
|
flightPath.setMap(map);
|
||||||
|
}""" % (latitude, longitude)
|
||||||
|
|
||||||
|
# Google Maps Markers only...
|
||||||
|
elif self.googleopts == "Markers":
|
||||||
|
if (not midX_ and not midY_):
|
||||||
|
data = place_lat_long[0]
|
||||||
|
midX_, midY_ = conv_lat_lon( data[0], data[1], "D.D8" )
|
||||||
|
jsc += """
|
||||||
|
var centre = new google.maps.LatLng(%s, %s);
|
||||||
|
var gpsCoords = [""" % (midX_, midY_)
|
||||||
|
for index in xrange(0, (number_markers - 1)):
|
||||||
|
data = place_lat_long[index]
|
||||||
|
jsc += """ new google.maps.LatLng(%s, %s),""" % ( data[0], data[1] )
|
||||||
|
data = place_lat_long[-1]
|
||||||
|
jsc += """ new google.maps.LatLng(%s, %s)
|
||||||
|
];
|
||||||
|
var markers = [];
|
||||||
|
var iterator = 0;
|
||||||
|
var map;
|
||||||
|
|
||||||
|
function initialize() {
|
||||||
|
|
||||||
|
var mapOptions = {
|
||||||
|
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 < gpsCoords.length; i++) {
|
||||||
|
setTimeout(function() {
|
||||||
|
addMarker();
|
||||||
|
}, i * 200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addMarker() {
|
||||||
|
|
||||||
|
markers.push(new google.maps.Marker({
|
||||||
|
position: gpsCoords[iterator],
|
||||||
|
map: map,
|
||||||
|
draggable: true,
|
||||||
|
animation: google.maps.Animation.DROP
|
||||||
|
}));
|
||||||
|
iterator++;
|
||||||
|
}""" % (data[0], data[1], zoomlevel)
|
||||||
|
# there is no need to add an ending "</script>",
|
||||||
|
# as it will be added automatically by libhtml()!
|
||||||
|
|
||||||
with Html("div", class_ ="content", id ="FamilyMapDetail") as mapbackground:
|
with Html("div", class_ ="content", id ="FamilyMapDetail") as mapbackground:
|
||||||
body += mapbackground
|
body += mapbackground
|
||||||
|
|
||||||
# begin familymap division
|
|
||||||
with Html("div", id = ymap) as mapbody:
|
|
||||||
mapbackground += mapbody
|
|
||||||
|
|
||||||
# page message
|
# page message
|
||||||
msg = _("The place markers on this page represent a different location "
|
msg = _("The place markers on this page represent a different location "
|
||||||
"based upon your spouse, your children (if any), and your personal "
|
"based upon your spouse, your children (if any), and your personal "
|
||||||
"events and their places. The list has been sorted in chronological "
|
"events and their places. The list has been sorted in chronological "
|
||||||
"date order. Clicking on the place’s name in the References "
|
"date order(if any?), and then by latitude/ longitude. Clicking on the "
|
||||||
"will take you to that place’s page. Clicking on the markers "
|
"place’s name in the References will take you to that place’s page.")
|
||||||
"will display its place title.")
|
mapbackground += Html("p", msg, id = "description")
|
||||||
mapbody += Html("p", msg, id = "description")
|
|
||||||
|
|
||||||
xmap = ""
|
# if Google and Markers are selected, then add "Drop Markers" button?
|
||||||
if spanX in smallset:
|
if (self.mapservice == "Google" and self.googleopts == "Markers"):
|
||||||
xmap = "small"
|
button_ = Html("button", _("Drop Markers"), id ="drop", onclick ="drop()", inline =True)
|
||||||
elif spanX in middleset:
|
mapbackground += button_
|
||||||
xmap = "middle"
|
|
||||||
elif spanX in largeset:
|
|
||||||
xmap = "large"
|
|
||||||
xmap += "XMap"
|
|
||||||
|
|
||||||
# begin middle section division
|
|
||||||
with Html("div", id = xmap) as middlesection:
|
|
||||||
mapbody += middlesection
|
|
||||||
|
|
||||||
# begin inline javascript code
|
|
||||||
# because jsc is a string, it does NOT have to properly indented
|
|
||||||
with Html("script", type = "text/javascript") as jsc:
|
|
||||||
middlesection += jsc
|
|
||||||
|
|
||||||
jsc += """
|
|
||||||
var map;
|
|
||||||
|
|
||||||
function initialize() {
|
|
||||||
|
|
||||||
// create map object
|
|
||||||
map = new mxn.Mapstraction('map_canvas', 'googlev3');
|
|
||||||
|
|
||||||
// add map controls to image
|
|
||||||
map.addControls({
|
|
||||||
pan: true,
|
|
||||||
zoom: 'large',
|
|
||||||
scale: true,
|
|
||||||
disableDoubleClickZoom: true,
|
|
||||||
keyboardShortcuts: true,
|
|
||||||
scrollwheel: false,
|
|
||||||
map_type: true
|
|
||||||
});"""
|
|
||||||
|
|
||||||
for (lat, long, p, h, d) in place_lat_long:
|
|
||||||
jsc += """ add_markers(%s, %s, "%s");""" % ( lat, long, p )
|
|
||||||
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:
|
|
||||||
|
|
||||||
# set southWest and northEast boundaries as spanY is greater than 20
|
|
||||||
jsc += """
|
|
||||||
// boundary southWest equals bottom left GPS Coordinates
|
|
||||||
var southWest = new mxn.LatLonPoint(%s, %s);""" % (minX, minY)
|
|
||||||
jsc += """
|
|
||||||
// boundary northEast equals top right GPS Coordinates
|
|
||||||
var northEast = new mxn.LatLonPoint(%s, %s);""" % (maxX, maxY)
|
|
||||||
jsc += """
|
|
||||||
var bounds = new google.maps.LatLngBounds(southWest, northEast);
|
|
||||||
map.fitBounds(bounds);"""
|
|
||||||
|
|
||||||
# include add_markers function
|
|
||||||
jsc += """
|
|
||||||
function add_markers(latitude, longitude, title) {
|
|
||||||
|
|
||||||
var latlon = new mxn.LatLonPoint(latitude, longitude);
|
|
||||||
var marker = new mxn.Marker(latlon);
|
|
||||||
|
|
||||||
marker.setInfoBubble(title);
|
|
||||||
|
|
||||||
map.addMarker(marker, true);"""
|
|
||||||
|
|
||||||
# set zoomlevel for size of map
|
|
||||||
if spanY in smallset:
|
|
||||||
zoomlevel = 7
|
|
||||||
elif spanY in middleset:
|
|
||||||
zoomlevel = 4
|
|
||||||
elif spanY in largeset:
|
|
||||||
zoomlevel = 4
|
|
||||||
else:
|
|
||||||
zoomlevel = 1
|
|
||||||
|
|
||||||
jsc += """
|
|
||||||
map.setCenterAndZoom(latlon, %d);
|
|
||||||
}""" % zoomlevel
|
|
||||||
|
|
||||||
# there is no need to add an ending "</script>",
|
|
||||||
# as it will be added automatically!
|
|
||||||
|
|
||||||
# here is where the map is held in the CSS/ Page
|
# here is where the map is held in the CSS/ Page
|
||||||
middlesection += Html("div", id ="map_canvas",
|
with Html("div", id ="map_canvas", inline =True) as canvas:
|
||||||
style ='width: 1600px; height: 1200px;', inline = True)
|
mapbackground += canvas
|
||||||
|
|
||||||
# add fullclear for proper styling
|
if self.mapservice == "OpenStreetMap":
|
||||||
middlesection += fullclear
|
with Html("script", type ="text/javascript") as jsc:
|
||||||
|
mapbackground += jsc
|
||||||
|
|
||||||
|
if number_markers == 1:
|
||||||
|
data = place_lat_long[0]
|
||||||
|
jsc += openstreet_jsc % (Utils.xml_lang()[3:5].lower(), data[0], data[1] )
|
||||||
|
else:
|
||||||
|
jsc += """
|
||||||
|
OpenLayers.Lang.setCode("%s");
|
||||||
|
|
||||||
|
map = new OpenLayers.Map("map_canvas");
|
||||||
|
map.addLayer(new OpenLayers.Layer.OSM());
|
||||||
|
|
||||||
|
epsg4326 = new OpenLayers.Projection("EPSG:4326"); //WGS 1984 projection
|
||||||
|
projectTo = map.getProjectionObject(); //The map projection (Spherical Mercator)
|
||||||
|
|
||||||
|
var centre = new OpenLayers.LonLat( %s, %s ).transform(epsg4326, projectTo);
|
||||||
|
var zoom = %d;
|
||||||
|
map.setCenter(centre, zoom);
|
||||||
|
|
||||||
|
var vectorLayer = new OpenLayers.Layer.Vector("Overlay");""" % (Utils.xml_lang()[3:5].lower(),
|
||||||
|
midY_, midX_, zoomlevel)
|
||||||
|
for (latitude, longitude, pname, h, d) in place_lat_long:
|
||||||
|
jsc += """
|
||||||
|
var feature = new OpenLayers.Feature.Vector(
|
||||||
|
new OpenLayers.Geometry.Point( %s, %s ).transform(epsg4326, projectTo),
|
||||||
|
{description:'%s'}
|
||||||
|
);
|
||||||
|
vectorLayer.addFeatures(feature);""" % (longitude, latitude, pname)
|
||||||
|
jsc += """
|
||||||
|
map.addLayer(vectorLayer);
|
||||||
|
|
||||||
|
//Add a selector control to the vectorLayer with popup functions
|
||||||
|
var controls = {
|
||||||
|
selector: new OpenLayers.Control.SelectFeature(vectorLayer, { onSelect:
|
||||||
|
createPopup, onUnselect: destroyPopup })
|
||||||
|
};
|
||||||
|
|
||||||
|
function createPopup(feature) {
|
||||||
|
feature.popup = new OpenLayers.Popup.FramedCloud("pop",
|
||||||
|
feature.geometry.getBounds().getCenterLonLat(),
|
||||||
|
null,
|
||||||
|
'<div id="geo-info">'+feature.attributes.description+'</div>',
|
||||||
|
null,
|
||||||
|
true,
|
||||||
|
function() { controls['selector'].unselectAll(); }
|
||||||
|
);
|
||||||
|
//feature.popup.closeOnMove = true;
|
||||||
|
map.addPopup(feature.popup);
|
||||||
|
}
|
||||||
|
|
||||||
|
function destroyPopup(feature) {
|
||||||
|
feature.popup.destroy();
|
||||||
|
feature.popup = null;
|
||||||
|
}
|
||||||
|
map.addControl(controls['selector']);
|
||||||
|
controls['selector'].activate();"""
|
||||||
|
|
||||||
with Html("div", class_ ="subsection", id ="references") as section:
|
with Html("div", class_ ="subsection", id ="references") as section:
|
||||||
mapbackground += section
|
mapbackground += section
|
||||||
@ -4233,7 +4270,8 @@ class IndividualPage(BasePage):
|
|||||||
ordered = Html("ol")
|
ordered = Html("ol")
|
||||||
section += ordered
|
section += ordered
|
||||||
|
|
||||||
# 0 = latitude, 1 = longitude, 2 = place title, 3 = handle, 4 = date
|
# 0 = latitude, 1 = longitude, 2 = place title, 3 = handle, and 4 = date
|
||||||
|
place_lat_long = sorted(place_lat_long, key =operator.itemgetter(4, 3, 0, 1))
|
||||||
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 =self.up))
|
list = Html("li", self.place_link(handle, pname, up =self.up))
|
||||||
@ -4246,8 +4284,12 @@ 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
|
# add body id for this page...
|
||||||
body.attr = 'onload = "initialize();" id = "FamilyMap"'
|
body.attr = 'id ="FamilyMap" '
|
||||||
|
|
||||||
|
# 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
|
||||||
@ -4264,7 +4306,7 @@ class IndividualPage(BasePage):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# create family map page
|
# create family map page
|
||||||
self._create_family_map(person)
|
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:
|
||||||
@ -5669,6 +5711,8 @@ class NavWebReport(Report):
|
|||||||
# Place Map tab options
|
# Place Map tab options
|
||||||
self.placemappages = self.options['placemappages']
|
self.placemappages = self.options['placemappages']
|
||||||
self.familymappages = self.options['familymappages']
|
self.familymappages = self.options['familymappages']
|
||||||
|
self.mapservice = self.options['mapservice']
|
||||||
|
self.googleopts = self.options['googleopts']
|
||||||
|
|
||||||
if self.use_home:
|
if self.use_home:
|
||||||
self.index_fname = "index"
|
self.index_fname = "index"
|
||||||
@ -5863,15 +5907,11 @@ 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 style sheet if using Place or Family Map pages?
|
||||||
if self.placemappages or self.familymappages:
|
if (self.placemappages or self.familymappages):
|
||||||
fname = CSS["NarrativeMaps"]["filename"]
|
fname = CSS["NarrativeMaps"]["filename"]
|
||||||
self.copy_file(fname, "narrative-maps.css", "styles")
|
self.copy_file(fname, "narrative-maps.css", "styles")
|
||||||
|
|
||||||
for from_path in CSS["NarrativeMaps"]["javascript"]:
|
|
||||||
fdir, fname = os.path.split(from_path)
|
|
||||||
self.copy_file( from_path, fname, "mapstraction" )
|
|
||||||
|
|
||||||
imgs = []
|
imgs = []
|
||||||
|
|
||||||
# Copy the Creative Commons icon if the Creative Commons
|
# Copy the Creative Commons icon if the Creative Commons
|
||||||
@ -6707,32 +6747,49 @@ class NavWebOptions(MenuReportOptions):
|
|||||||
addopt( "inc_addressbook", inc_addressbook )
|
addopt( "inc_addressbook", inc_addressbook )
|
||||||
|
|
||||||
def __add_place_map_options(self, menu):
|
def __add_place_map_options(self, menu):
|
||||||
|
"""
|
||||||
category_name = _("Place Maps")
|
options for the Place Map tab.
|
||||||
|
"""
|
||||||
|
category_name = _("Place Map Options")
|
||||||
addopt = partial(menu.add_option, category_name)
|
addopt = partial(menu.add_option, category_name)
|
||||||
|
|
||||||
self.__placemappages = BooleanOption(_("Include Place map on Place Pages (GoogleMaps)"), False)
|
mapopts = [
|
||||||
|
[_("Google"), "Google"],
|
||||||
|
[_("OpenStreetMap"), "OpenStreetMap"] ]
|
||||||
|
self.__mapservice = EnumeratedListOption(_("Map Service"), mapopts[0][1])
|
||||||
|
for trans, opt in mapopts:
|
||||||
|
self.__mapservice.add_item(opt, trans)
|
||||||
|
self.__mapservice.set_help(_("Choose your choice of map service for "
|
||||||
|
"creating the Place Map Pages."))
|
||||||
|
self.__mapservice.connect("value-changed", self.__placemap_options)
|
||||||
|
addopt("mapservice", self.__mapservice)
|
||||||
|
|
||||||
|
self.__placemappages = BooleanOption(_("Include Place map on Place Pages"), False)
|
||||||
self.__placemappages.set_help(_("Whether to include a place map on the Place Pages, "
|
self.__placemappages.set_help(_("Whether to include a place map on the Place Pages, "
|
||||||
"where Latitude/ Longitude are available."))
|
"where Latitude/ Longitude are available."))
|
||||||
self.__placemappages.connect("value-changed", self.__placemap_changed)
|
self.__placemappages.connect("value-changed", self.__placemap_options)
|
||||||
addopt("placemappages", self.__placemappages)
|
addopt("placemappages", self.__placemappages)
|
||||||
|
|
||||||
self.__openstreetmap = BooleanOption(_("Include Place map on Place Pages (Openstreetmaps)"), False)
|
self.__familymappages = BooleanOption(_("Include Family Map Pages with "
|
||||||
self.__openstreetmap.set_help(_("Whether to include a place map on the Place Pages, "
|
|
||||||
"where Latitude/ Longitude are available."))
|
|
||||||
self.__openstreetmap.connect("value-changed", self.__osm_changed)
|
|
||||||
addopt("openstreetmap", self.__openstreetmap)
|
|
||||||
|
|
||||||
self.__placemap_changed()
|
|
||||||
self.__osm_changed()
|
|
||||||
|
|
||||||
familymappages = BooleanOption(_("Include Family Map Pages with "
|
|
||||||
"all places shown on the map"), False)
|
"all places shown on the map"), False)
|
||||||
familymappages.set_help(_("Whether or not to add an individual page map "
|
self.__familymappages.set_help(_("Whether or not to add an individual page map "
|
||||||
"showing all the places on this page. "
|
"showing all the places on this page. "
|
||||||
"This will allow you to see how your family "
|
"This will allow you to see how your family "
|
||||||
"traveled around the country."))
|
"traveled around the country."))
|
||||||
addopt( "familymappages", familymappages )
|
self.__familymappages.connect("value-changed", self.__placemap_options)
|
||||||
|
addopt("familymappages", self.__familymappages)
|
||||||
|
|
||||||
|
googleopts = [
|
||||||
|
(_("Markers"), "Markers"),
|
||||||
|
(_("Family Links"), "FamilyLinks") ]
|
||||||
|
self.__googleopts = EnumeratedListOption(_("Google/ FamilyMap Option"), googleopts[0][1])
|
||||||
|
for trans, opt in googleopts:
|
||||||
|
self.__googleopts.add_item(opt, trans)
|
||||||
|
self.__googleopts.set_help(_("Select which option that you would like "
|
||||||
|
"to have for the Google Maps Family Map pages..."))
|
||||||
|
addopt("googleopts", self.__googleopts)
|
||||||
|
|
||||||
|
self.__placemap_options()
|
||||||
|
|
||||||
def __archive_changed(self):
|
def __archive_changed(self):
|
||||||
"""
|
"""
|
||||||
@ -6820,25 +6877,25 @@ 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 __placemap_changed(self):
|
def __placemap_options(self):
|
||||||
"""
|
"""
|
||||||
Handles the changing nature of the place maps
|
Handles the changing nature of the place map Options
|
||||||
"""
|
"""
|
||||||
|
# get values for all Place Map Options tab...
|
||||||
|
place_active = self.__placemappages.get_value()
|
||||||
|
family_active = self.__familymappages.get_value()
|
||||||
|
mapservice_opts = self.__mapservice.get_value()
|
||||||
|
google_opts = self.__googleopts.get_value()
|
||||||
|
|
||||||
if self.__placemappages.get_value():
|
if (place_active or family_active):
|
||||||
self.__openstreetmap.set_available(False)
|
self.__mapservice.set_available(True)
|
||||||
else:
|
else:
|
||||||
self.__openstreetmap.set_available(True)
|
self.__mapservice.set_available(False)
|
||||||
|
|
||||||
def __osm_changed(self):
|
if (family_active and mapservice_opts == "Google"):
|
||||||
"""
|
self.__googleopts.set_available(True)
|
||||||
Handles the changing nature of OpenStreetMap
|
|
||||||
"""
|
|
||||||
|
|
||||||
if self.__openstreetmap.get_value():
|
|
||||||
self.__placemappages.set_available(False)
|
|
||||||
else:
|
else:
|
||||||
self.__placemappages.set_available(True)
|
self.__googleopts.set_available(False)
|
||||||
|
|
||||||
# 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):
|
||||||
|
@ -22,29 +22,12 @@
|
|||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
Body element
|
Family Map body element
|
||||||
------------------------------------------------- */
|
------------------------------------------------- */
|
||||||
body#FamilyMap {
|
body#FamilyMap {
|
||||||
|
margin-left: 2px;
|
||||||
|
margin-right: 2px;
|
||||||
background-color: #FFF;
|
background-color: #FFF;
|
||||||
margin: 0 auto;
|
|
||||||
width: 1060px;
|
|
||||||
padding: 0px 4px 0px 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Mapstraction
|
|
||||||
------------------------------------------------- */
|
|
||||||
div#mapstraction {
|
|
||||||
height: 580px;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Middle
|
|
||||||
------------------------------------------------- */
|
|
||||||
div#middle {
|
|
||||||
float: center;
|
|
||||||
height: 440px;
|
|
||||||
width: 90%;
|
|
||||||
margin: 10px 2% 10px 2%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* geo-info Bubble
|
/* geo-info Bubble
|
||||||
@ -53,19 +36,23 @@ div#geo-info {
|
|||||||
font: bold 11px sans-serif;
|
font: bold 11px sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* GoogleV3
|
/* map_canvas-- place map holder
|
||||||
------------------------------------------------- */
|
------------------------------------------------- */
|
||||||
div#googlev3 {
|
div#map_canvas {
|
||||||
height: 500px;
|
margin: 5px;
|
||||||
width: 600px;
|
border: solid 4px #00029D;
|
||||||
border: solid 1px #000;
|
width: 1200px;
|
||||||
|
height: 800px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* **************************************************************************************
|
/* button
|
||||||
|
|
||||||
MiddleSection
|
|
||||||
------------------------------------------------- */
|
------------------------------------------------- */
|
||||||
div#middlesection {
|
button#drop {
|
||||||
float: center;
|
font-weight: bold;
|
||||||
overflow-y: hidden;
|
margin-left: 10px;
|
||||||
|
padding: 5px;
|
||||||
|
text-align: center;
|
||||||
|
width: 100px;
|
||||||
|
height: 30px;
|
||||||
|
border: solid 2px #00029D;
|
||||||
}
|
}
|
||||||
|
@ -108,11 +108,7 @@ def load_on_reg(dbstate, uistate, plugin):
|
|||||||
|
|
||||||
# narrative-maps style sheet for NarrativeWeb place maps
|
# narrative-maps style sheet for NarrativeWeb place maps
|
||||||
["NarrativeMaps", 0, "",
|
["NarrativeMaps", 0, "",
|
||||||
path_css("Mapstraction.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"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user