Added extra features to OpenStreetMap in Place Maps.
svn: r17966
This commit is contained in:
parent
59c793608c
commit
888e464700
@ -121,21 +121,23 @@ _COPY_OPTIONS = [
|
|||||||
|
|
||||||
# NarrativeWeb javascript code for PlacePage's "Open Street Map"...
|
# NarrativeWeb javascript code for PlacePage's "Open Street Map"...
|
||||||
openstreet_jsc = """
|
openstreet_jsc = """
|
||||||
var marker;
|
OpenLayers.Lang.setCode("%s");
|
||||||
var map;
|
|
||||||
|
|
||||||
OpenLayers.Lang.setCode("%s");
|
function initialize() {
|
||||||
|
|
||||||
function initialize(){
|
|
||||||
map = new OpenLayers.Map("map_canvas");
|
map = new OpenLayers.Map("map_canvas");
|
||||||
|
map.addLayer(new OpenLayers.Layer.OSM());
|
||||||
|
|
||||||
var center = new OpenLayers.LonLat(%s, %s);
|
var lonLat = new OpenLayers.LonLat(%s, %s)
|
||||||
var zoom = 11;
|
.transform(
|
||||||
map.setCenter(center, zoom);
|
new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
|
||||||
|
map.getProjectionObject() // to Spherical Mercator Projection
|
||||||
|
);
|
||||||
|
var zoom =16;
|
||||||
|
map.setCenter(lonLat, zoom);
|
||||||
|
|
||||||
var osm = new OpenLayers.Layer.OSM("OpenStreetMap");
|
var osm = new OpenLayers.Layer.OSM("OpenStreetMap");
|
||||||
var markers = new OpenLayers.Layer.Markers("Markers");
|
var markers = new OpenLayers.Layer.Markers( "Markers" );
|
||||||
markers.addMarker(new OpenLayers.Marker(marker));
|
markers.addMarker(new OpenLayers.Marker(lonLat));
|
||||||
|
|
||||||
map.addLayers([osm, markers]);
|
map.addLayers([osm, markers]);
|
||||||
|
|
||||||
@ -144,10 +146,7 @@ openstreet_jsc = """
|
|||||||
|
|
||||||
// add a layer switcher
|
// add a layer switcher
|
||||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||||
|
}"""
|
||||||
map.zoomToMaxExtent();
|
|
||||||
|
|
||||||
}"""
|
|
||||||
|
|
||||||
# NarrativeWeb javascript code for PlacePage's "Google Maps"...
|
# NarrativeWeb javascript code for PlacePage's "Google Maps"...
|
||||||
google_jsc = """
|
google_jsc = """
|
||||||
|
@ -1134,16 +1134,15 @@ class BasePage(object):
|
|||||||
|
|
||||||
# Header constants
|
# Header constants
|
||||||
xmllang = Utils.xml_lang()
|
xmllang = Utils.xml_lang()
|
||||||
_META1 = 'name="generator" content="%s %s %s"' % (
|
_META1 = 'name ="viewport" content ="width=device-width, initial-scale=1.0, user-scalable=yes" '
|
||||||
|
_META2 = 'name="generator" content="%s %s %s"' % (
|
||||||
const.PROGRAM_NAME, const.VERSION, const.URL_HOMEPAGE)
|
const.PROGRAM_NAME, const.VERSION, const.URL_HOMEPAGE)
|
||||||
|
_META3 = 'name="author" content="%s"' % self.author
|
||||||
_META2 = 'name="author" content="%s"' % self.author
|
|
||||||
_META3 = 'name ="viewport" content ="width=device-width, initial-scale=1.0, user-scalable=yes" '
|
|
||||||
|
|
||||||
page, head, body = Html.page('%s - %s' %
|
page, head, body = Html.page('%s - %s' %
|
||||||
(html_escape(self.title_str),
|
(html_escape(self.title_str.strip()),
|
||||||
html_escape(title)),
|
html_escape(title)),
|
||||||
self.report.encoding, xmllang )
|
self.report.encoding, xmllang)
|
||||||
|
|
||||||
# temporary fix for .php parsing error
|
# temporary fix for .php parsing error
|
||||||
if self.ext in [".php", ".php3", ".cgi"]:
|
if self.ext in [".php", ".php3", ".cgi"]:
|
||||||
@ -2592,13 +2591,11 @@ class PlacePage(BasePage):
|
|||||||
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":
|
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:
|
||||||
# try to add OpenLayers specific javascript code ...
|
|
||||||
if self.mapservice == "OpenStreetMap":
|
|
||||||
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)
|
||||||
|
|
||||||
@ -2609,27 +2606,16 @@ class PlacePage(BasePage):
|
|||||||
with Html("div", id ="map_canvas") as canvas:
|
with Html("div", id ="map_canvas") as canvas:
|
||||||
placedetail += canvas
|
placedetail += canvas
|
||||||
|
|
||||||
if self.mapservice == "OpenStreetMap":
|
|
||||||
url = 'http://www.openstreetmap.com/?lat=%s&lon=%s&zoom=11&layers=M' % (
|
|
||||||
latitude, longitude)
|
|
||||||
canvas += Html("object", type ="text/html", width ="98%", height ="98%",
|
|
||||||
data =url)
|
|
||||||
|
|
||||||
# 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:
|
||||||
if self.mapservice == "Google":
|
|
||||||
head += jsc
|
head += jsc
|
||||||
|
|
||||||
# in Google Maps, they use Latitude before Longitude
|
if self.mapservice == "Google":
|
||||||
jsc += google_jsc % (latitude, longitude)
|
jsc += google_jsc % (latitude, longitude)
|
||||||
else:
|
else:
|
||||||
canvas += jsc
|
|
||||||
|
|
||||||
# in OpenStreetMap, they use Longitude before Latitude
|
|
||||||
jsc += openstreet_jsc % (Utils.xml_lang()[3:5].lower(),
|
jsc += openstreet_jsc % (Utils.xml_lang()[3:5].lower(),
|
||||||
longitude, latitude)
|
longitude, latitude)
|
||||||
|
|
||||||
# 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!
|
||||||
|
|
||||||
|
@ -69,3 +69,12 @@ div#middlesection {
|
|||||||
float: center;
|
float: center;
|
||||||
overflow-y: hidden;
|
overflow-y: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* map_canvas-- place map holder
|
||||||
|
------------------------------------------------- */
|
||||||
|
div#map_canvas {
|
||||||
|
margin-left: 30px;
|
||||||
|
border: solid 4px #000;
|
||||||
|
width: 900px;
|
||||||
|
height: 600px;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user