- added GUI support for language switching

- first tests for support of printing
This commit is contained in:
DennisSchiefer 2012-04-03 21:13:44 +02:00
parent 4638e7c24d
commit abba49a44e
14 changed files with 395 additions and 12 deletions

View File

@ -29,8 +29,10 @@ width: null,
init: function() {
OSRM.GUI.visible = true;
OSRM.GUI.width = document.getElementById("main-wrapper").clientWidth;
// translate
},
// set language dependent labels
setLanguage: function() {
document.getElementById("open-josm").innerHTML = OSRM.loc("OPEN_JOSM");
document.getElementById("open-osmbugs").innerHTML = OSRM.loc("OPEN_OSMBUGS");
document.getElementById("gui-reset").innerHTML = OSRM.loc("GUI_RESET");

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

View File

@ -0,0 +1,64 @@
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU AFFERO General Public License as published by
the Free Software Foundation; either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or see http://www.gnu.org/licenses/agpl.txt.
*/
// OSRM localization
// [German language support]
OSRM.Localization["de"] = {
//gui
"OPEN_JOSM": "JOSM",
"OPEN_OSMBUGS": "OSM Bugs",
"GUI_START": "Start",
"GUI_END": "Ziel",
"GUI_RESET": "Reset",
"GUI_SEARCH": "Zeigen",
"GUI_REVERSE": "Umdrehen",
"GUI_OPTIONS": "Kartenwerkzeuge",
"GUI_HIGHLIGHT_UNNAMED_ROADS": "Unbenannte Straßen hervorheben",
"GUI_START_TOOLTIP": "Startposition eingeben",
"GUI_END_TOOLTIP": "Zielposition eingeben",
"GUI_LEGAL_NOTICE": "GUI2 v"+OSRM.VERSION+" "+OSRM.DATE+" - OSRM hosting by <a href='http://algo2.iti.kit.edu/'>KIT</a> - Geocoder by <a href='http://www.osm.org/'>OSM</a>",
// geocoder
"SEARCH_RESULTS": "Suchergebnisse",
"TIMED_OUT": "Zeitüberschreitung",
"NO_RESULTS_FOUND": "Keine Ergebnisse gefunden",
"NO_RESULTS_FOUND_SOURCE": "Keine Ergebnisse gefunden für Start",
"NO_RESULTS_FOUND_TARGET": "Keine Ergebnisse gefunden für Ziel",
// routing
"ROUTE_DESCRIPTION": "Routenbeschreibung",
"GET_LINK_TO_ROUTE": "Generiere Link",
"GENERATE_LINK_TO_ROUTE": "Warte auf Antwort",
"LINK_TO_ROUTE_TIMEOUT": "nicht möglich",
"GPX_FILE": "GPX Datei",
"DISTANCE": "Distanz",
"DURATION": "Dauer",
"YOUR_ROUTE_IS_BEING_COMPUTED": "Ihre Route wird berechnet",
"NO_ROUTE_FOUND": "Keine Route hierher möglich",
// directions
"N": "Norden",
"O": "Ost",
"S": "Süden",
"W": "Westen",
"NO": "Nordost",
"SO": "Südost",
"SW": "Südwest",
"NW": "Nordwest"
};
// set GUI language on load
OSRM.GUI.setLanguage();

View File

@ -0,0 +1,64 @@
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU AFFERO General Public License as published by
the Free Software Foundation; either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or see http://www.gnu.org/licenses/agpl.txt.
*/
// OSRM localization
// [English language support]
OSRM.Localization["en"] = {
//gui
"OPEN_JOSM": "JOSM",
"OPEN_OSMBUGS": "OSM Bugs",
"GUI_START": "Start",
"GUI_END": "End",
"GUI_RESET": "&nbsp;&nbsp;Reset&nbsp;&nbsp;",
"GUI_SEARCH": "&nbsp;&nbsp;Show&nbsp;&nbsp;",
"GUI_REVERSE": "Reverse",
"GUI_OPTIONS": "Mapping Tools",
"GUI_HIGHLIGHT_UNNAMED_ROADS": "Highlight unnamed streets",
"GUI_START_TOOLTIP": "Enter start",
"GUI_END_TOOLTIP": "Enter destination",
"GUI_LEGAL_NOTICE": "GUI2 v"+OSRM.VERSION+" "+OSRM.DATE+" - OSRM hosting by <a href='http://algo2.iti.kit.edu/'>KIT</a> - Geocoder by <a href='http://www.osm.org/'>OSM</a>",
// geocoder
"SEARCH_RESULTS": "Search Results",
"TIMED_OUT": "Timed Out",
"NO_RESULTS_FOUND": "No results found",
"NO_RESULTS_FOUND_SOURCE": "No results found for start",
"NO_RESULTS_FOUND_TARGET": "No results found for end",
//routing
"ROUTE_DESCRIPTION": "Route Description",
"GET_LINK_TO_ROUTE": "Generate Link",
"GENERATE_LINK_TO_ROUTE": "waiting for link",
"LINK_TO_ROUTE_TIMEOUT": "not available",
"GPX_FILE": "GPX File",
"DISTANCE": "Distance",
"DURATION": "Duration",
"YOUR_ROUTE_IS_BEING_COMPUTED": "Your route is being computed",
"NO_ROUTE_FOUND": "No route possible",
// directions
"N": "north",
"E": "east",
"S": "south",
"W": "west",
"NE": "northeast",
"SE": "southeast",
"SW": "southwest",
"NW": "northwest"
};
//set GUI language on load
OSRM.GUI.setLanguage();

View File

@ -0,0 +1,74 @@
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU AFFERO General Public License as published by
the Free Software Foundation; either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or see http://www.gnu.org/licenses/agpl.txt.
*/
// OSRM localization
// [basic localization options]
OSRM.Localization = {
supported_languages: ["en", "de"],
// initialize localization
init: function() {
// create dropdown menu
var select = document.createElement('select');
select.id = "language-toggle";
select.onchange = function() { OSRM.Localization.change(this.value); };
// fill dropdown menu
for(var i=0, size=OSRM.Localization.supported_languages.length; i<size; i++) {
var option=document.createElement("option");
option.innerHTML = OSRM.Localization.supported_languages[i];
option.value = OSRM.Localization.supported_languages[i];
select.appendChild(option);
}
// add element to DOM
var main_input_header = document.getElementById('main-input-header');
main_input_header.insertBefore(select,main_input_header.firstChild);
// initialize default language
OSRM.Localization.change( OSRM.DEFAULTS.LANGUAGE );
},
// perform language change
change: function(language) {
OSRM.DEFAULTS.LANGUAGE = language;
if( OSRM.Localization[language]) {
OSRM.GUI.setLanguage();
} else {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = "Localization/OSRM.Locale."+language+".js";
document.head.appendChild(script);
}
},
// if existing, return localized string -> English string -> input string
translate: function(text) {
if( OSRM.Localization[OSRM.DEFAULTS.LANGUAGE] && OSRM.Localization[OSRM.DEFAULTS.LANGUAGE][text] )
return OSRM.Localization[OSRM.DEFAULTS.LANGUAGE][text];
else if( OSRM.Localization["en"] && OSRM.Localization["en"][text] )
return OSRM.Localization["en"][text];
else
return text;
}
};
// shorter call to translate function
OSRM.loc = OSRM.Localization.translate;

View File

@ -112,9 +112,9 @@ html, body, #map {
.main-toggle-out
{
cursor:pointer;
position:absolute;
/* position:absolute;
right:5px;
top:5px;
top:5px;*/
width:16px;
height:16px;
background-image:url("images/cancel.png");
@ -322,7 +322,6 @@ html, body, #map {
user-select: text;
}
/* buttons */
.button
{
@ -348,7 +347,7 @@ html, body, #map {
color:#FF0000;
}
/* delete marker */
.delete-marker
{
cursor:pointer;
@ -367,4 +366,28 @@ html, body, #map {
.delete-marker:active
{
background-image:url("images/cancel_active.png");
}
/* printer button */
.printer-inactive
{
cursor:pointer;
width:16px;
height:16px;
background-image:url("images/printer_inactive.png");
}
.printer
{
cursor:pointer;
width:16px;
height:16px;
background-image:url("images/printer.png");
}
.printer:hover
{
background-image:url("images/printer_hover.png");
}
.printer:active
{
background-image:url("images/printer_active.png");
}

View File

@ -64,7 +64,8 @@ or see http://www.gnu.org/licenses/agpl.txt.
<script src="OSRM.Browser.js" type="text/javascript"></script>
<script src="OSRM.JSONP.js" type="text/javascript"></script>
<script src="OSRM.Localization.js" type="text/javascript"></script>
<script src="Localization/OSRM.Localization.js" type="text/javascript"></script>
<script src="Printing/OSRM.Printing.js" type="text/javascript"></script>
<script src="OSRM.Utils.js" type="text/javascript"></script>
</head>
@ -78,16 +79,23 @@ or see http://www.gnu.org/licenses/agpl.txt.
<!-- show ui blob -->
<div id="blob-wrapper" class="gui-wrapper">
<div id="blob-input" class="gui-box">
<div class="main-toggle-in" onclick="OSRM.GUI.toggleMain()"></div>
<div class="main-toggle-in" onclick="OSRM.GUI.toggleMain();"></div>
</div>
</div>
<!-- show main gui -->
<div id="main-wrapper" class="gui-wrapper">
<div id="main-wrapper" class="gui-wrapper not-selectable">
<!-- input box -->
<div class="gui-box not-selectable" id="main-input">
<div class="main-toggle-out" onclick="OSRM.GUI.toggleMain()"></div>
<div class="gui-box" id="main-input">
<div style="position:absolute;display:table;width:390px;" id="main-input-header">
<div style="display:table-cell;background-repeat:no-repeat;background-position:center;" id="printer" class="printer" onclick="OSRM.Printing.print();"></div>
<div style="display:table-cell;width:8px;background-repeat:no-repeat;background-position:center;"></div>
<div style="display:table-cell;background-repeat:no-repeat;background-position:center;" class="main-toggle-out" onclick="OSRM.GUI.toggleMain()"></div>
</div>
<img id="osrm-logo" alt="OSRM Logo" src="images/osrm-logo.png" />
<!-- source/target input -->

View File

@ -27,6 +27,7 @@ OSRM.init = function() {
OSRM.prefetchImages();
OSRM.prefetchIcons();
OSRM.Localization.init();
OSRM.GUI.init();
OSRM.Map.init();
OSRM.Routing.init();
@ -53,7 +54,11 @@ OSRM.prefetchImages = function() {
'images/cancel_hover.png',
'images/restore.png',
'images/restore_active.png',
'images/restore_hover.png'
'images/restore_hover.png',
'images/printer.png',
'images/printer_active.png',
'images/printer_hover.png',
'images/printer_inactive.png'
];
for(var i=0; i<images.length; i++) {

View File

@ -0,0 +1,60 @@
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU AFFERO General Public License as published by
the Free Software Foundation; either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or see http://www.gnu.org/licenses/agpl.txt.
*/
// OSRM printer
// [printing support]
OSRM.Printing = {
x: function(){
OSRM.printwindow.test();
// var pos1 = OSRM.printwindow.document.getElementById('map1');
// var pos2 = OSRM.printwindow.document.getElementById('map2');
// // setup map
// var osmorgURL = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
// osmorgOptions = {maxZoom: 18};
// var osmorg = new L.TileLayer(osmorgURL, osmorgOptions);
// var temp1 = new OSRM.MapView(pos1, {
// center: new L.LatLng(51.505, -0.09),
// zoom: 13,
// zoomAnimation: false, // false: removes animations and hiding of routes during zoom
// fadeAnimation: false,
// layers: [osmorg]
// });
// var osmorgURL = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
// osmorgOptions = {maxZoom: 18};
// var osmorg = new L.TileLayer(osmorgURL, osmorgOptions);
// var temp2 = new OSRM.MapView(pos2, {
// center: new L.LatLng(51.505, -0.09),
// zoom: 13,
// zoomAnimation: false, // false: removes animations and hiding of routes during zoom
// fadeAnimation: false,
// layers: [osmorg]
// });
},
// react to click
print: function() {
OSRM.printwindow = window.open("printing.html", "Popupfenster", "width=400,height=300,resizable=yes");
// fenster.document.write("<div id='map1' style='width:100px;height:100px'>a</div><div id='map2' style='width:100px;height:100px'>b</div>");
OSRM.printwindow.focus();
OSRM.printwindow.addEventListener("DOMContentLoaded", OSRM.Printing.x, false);
}
};

View File

@ -0,0 +1,83 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU AFFERO General Public License as published by
the Free Software Foundation; either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or see http://www.gnu.org/licenses/agpl.txt.
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- head -->
<head>
<!-- metatags -->
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>OSRM Website</title>
<meta name="description" content="OSRM Website"/>
<meta name="author" content="Dennis Schieferdecker" />
<!-- favicon -->
<link rel="shortcut icon" href="images/osrm-favicon.ico" type="image/x-icon" />
<!-- stylesheets -->
<link rel="stylesheet" href="leaflet/leaflet.css" type="text/css"/>
<!--[if lte IE 8]><link rel="stylesheet" href="leaflet/leaflet.ie.css" type="text/css"/><![endif]-->
<!-- scripts -->
<script src="leaflet/leaflet-src.js" type="text/javascript"></script>
<script>
function test() {
// setup map
var osmorgURL = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
osmorgOptions = {maxZoom: 18};
var osmorg = new L.TileLayer(osmorgURL, osmorgOptions);
var temp1 = new L.Map("map1", {
center: new L.LatLng(51.505, -0.09),
zoom: 13,
zoomAnimation: false, // false: removes animations and hiding of routes during zoom
fadeAnimation: false,
layers: [osmorg],
attributionControl: false,
zoomControl: false
});
var osmorgURL = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
osmorgOptions = {maxZoom: 18, attributionControl:false};
var osmorg = new L.TileLayer(osmorgURL, osmorgOptions);
var temp2 = new L.Map("map2", {
center: new L.LatLng(51.505, -0.09),
zoom: 13,
zoomAnimation: false, // false: removes animations and hiding of routes during zoom
fadeAnimation: false,
layers: [osmorg],
attributionControl: false,
zoomControl: false
});
}
</script>
</head>
<!-- body -->
<body>
<!--maps-->
<div id="map1" style='width:100px;height:100px'></div>
<div id="map2" style='width:100px;height:100px'></div>
</body>
</html>