Moved javascript map code from src/plugins/lib/libhtmlconst.py to NarrativeWeb. Fixed the single marker PlacePage.
svn: r18645
This commit is contained in:
parent
3584fd804f
commit
051da7cb87
@ -118,58 +118,3 @@ _COPY_OPTIONS = [
|
|||||||
|
|
||||||
_('No copyright notice'),
|
_('No copyright notice'),
|
||||||
]
|
]
|
||||||
|
|
||||||
# NarrativeWeb javascript code for PlacePage's "Open Street Map"...
|
|
||||||
openstreetmap_jsc = """
|
|
||||||
OpenLayers.Lang.setCode("%s");
|
|
||||||
|
|
||||||
map = new OpenLayers.Map("place_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());"""
|
|
||||||
|
|
||||||
# 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("place_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);
|
|
||||||
}
|
|
||||||
}"""
|
|
||||||
|
@ -113,26 +113,26 @@ from gui.pluginmanager import GuiPluginManager
|
|||||||
#------------------------------------------------
|
#------------------------------------------------
|
||||||
# javascript code for Google single Marker...
|
# javascript code for Google single Marker...
|
||||||
google_jsc = """
|
google_jsc = """
|
||||||
var map;
|
var myLatLng = new google.maps.LatLng(%s, %s);
|
||||||
|
|
||||||
function initialize() {
|
function initialize() {
|
||||||
var mapOptions = {
|
var mapOptions = {
|
||||||
scaleControl: true,
|
scaleControl: true,
|
||||||
panControl: true,
|
panControl: true,
|
||||||
backgroundColor: '#000000',
|
backgroundColor: '#000000',
|
||||||
zoom: 14,
|
draggable: true,
|
||||||
center: new google.maps.LatLng(0, 0),
|
zoom: 10,
|
||||||
|
center: myLatLng,
|
||||||
mapTypeId: google.maps.MapTypeId.ROADMAP
|
mapTypeId: google.maps.MapTypeId.ROADMAP
|
||||||
}
|
}
|
||||||
map = new google.maps.Map(document.getElementById("place_canvas"), mapOptions);
|
var map = new google.maps.Map(document.getElementById("place_canvas"), mapOptions);
|
||||||
|
|
||||||
var marker = new google.maps.Marker({
|
var marker = new google.maps.Marker({
|
||||||
position: new google.maps.LatLng(%s, %s),
|
position: myLatLng,
|
||||||
draggable: true,
|
draggable: true,
|
||||||
map: map,
|
title: "%s",
|
||||||
title: %s
|
map: map
|
||||||
});
|
});
|
||||||
google.maps.event.addDomListener(window, 'load', initialize);
|
|
||||||
}"""
|
}"""
|
||||||
|
|
||||||
# javascript code for Google's FamilyLinks...
|
# javascript code for Google's FamilyLinks...
|
||||||
@ -168,7 +168,6 @@ dropmarkers = """
|
|||||||
var iterator = 0;
|
var iterator = 0;
|
||||||
|
|
||||||
var tracelife = %s
|
var tracelife = %s
|
||||||
|
|
||||||
var map;
|
var map;
|
||||||
|
|
||||||
function initialize() {
|
function initialize() {
|
||||||
@ -178,7 +177,7 @@ dropmarkers = """
|
|||||||
zoom: %d,
|
zoom: %d,
|
||||||
mapTypeId: google.maps.MapTypeId.ROADMAP,
|
mapTypeId: google.maps.MapTypeId.ROADMAP,
|
||||||
center: new google.maps.LatLng(0, 0)
|
center: new google.maps.LatLng(0, 0)
|
||||||
};
|
}
|
||||||
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
|
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3290,6 +3289,7 @@ class PlacePage(BasePage):
|
|||||||
if self.placemappages:
|
if self.placemappages:
|
||||||
if (place and (place.lat and place.long)):
|
if (place and (place.lat and place.long)):
|
||||||
latitude, longitude = conv_lat_lon(place.get_latitude(), place.get_longitude(), "D.D8")
|
latitude, longitude = conv_lat_lon(place.get_latitude(), place.get_longitude(), "D.D8")
|
||||||
|
placetitle = place.get_title()
|
||||||
|
|
||||||
# add narrative-maps CSS...
|
# add narrative-maps CSS...
|
||||||
fname = "/".join(["styles", "narrative-maps.css"])
|
fname = "/".join(["styles", "narrative-maps.css"])
|
||||||
@ -3298,8 +3298,8 @@ class PlacePage(BasePage):
|
|||||||
|
|
||||||
# add MapService specific javascript code
|
# add MapService specific javascript code
|
||||||
if self.mapservice == "Google":
|
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:
|
else:
|
||||||
head += Html("script", type = "text/javascript",
|
head += Html("script", type = "text/javascript",
|
||||||
src = "http://www.openlayers.org/api/OpenLayers.js", inline = True)
|
src = "http://www.openlayers.org/api/OpenLayers.js", inline = True)
|
||||||
@ -3308,20 +3308,19 @@ class PlacePage(BasePage):
|
|||||||
placedetail += Html("h4", _("Place Map"), inline =True)
|
placedetail += Html("h4", _("Place Map"), inline =True)
|
||||||
|
|
||||||
# begin map_canvas division
|
# begin map_canvas division
|
||||||
with Html("div", id ="place_canvas") as canvas:
|
with Html("div", id ="place_canvas", inline = True) as canvas:
|
||||||
placedetail += canvas
|
placedetail += canvas
|
||||||
|
|
||||||
# begin inline javascript code
|
# begin inline javascript code
|
||||||
# because jsc is a docstring, 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:
|
||||||
|
|
||||||
if self.mapservice == "Google":
|
if self.mapservice == "Google":
|
||||||
head += jsc
|
head += jsc
|
||||||
|
|
||||||
# Google adds Latitude/ Longitude to its maps...
|
# Google adds Latitude/ Longitude to its maps...
|
||||||
jsc += google_jsc % (latitude, longitude, place.get_title())
|
jsc += google_jsc % (latitude, longitude, placetitle)
|
||||||
|
|
||||||
else:
|
elif self.mapservice == "OpenStreetMap":
|
||||||
canvas += jsc
|
canvas += jsc
|
||||||
|
|
||||||
# OpenStreetMap (OSM) adds Longitude/ Latitude to its maps,
|
# OpenStreetMap (OSM) adds Longitude/ Latitude to its maps,
|
||||||
@ -3329,10 +3328,7 @@ class PlacePage(BasePage):
|
|||||||
jsc += openstreetmap_jsc % (Utils.xml_lang()[3:5].lower(), longitude, latitude)
|
jsc += openstreetmap_jsc % (Utils.xml_lang()[3:5].lower(), longitude, latitude)
|
||||||
|
|
||||||
# add javascript function call to body element
|
# add javascript function call to body element
|
||||||
if self.mapservice == "Google":
|
body.attr +=' onload = "initialize();" '
|
||||||
pass
|
|
||||||
else:
|
|
||||||
body.attr +=' onload ="initialize();" '
|
|
||||||
|
|
||||||
# place references
|
# place references
|
||||||
reflist = self.display_references(place_list[place.handle])
|
reflist = self.display_references(place_list[place.handle])
|
||||||
|
Loading…
Reference in New Issue
Block a user