removal of dragger marker more consistent,
changed printing initialization to be more easily removable from GUI, localization bug fixes, added option to give language as get parameter (hl=),
This commit is contained in:
parent
b1631eff77
commit
888a5d04c8
@ -41,7 +41,6 @@ init: function() {
|
|||||||
// [TODO: switch to new event model]
|
// [TODO: switch to new event model]
|
||||||
document.getElementById("gui-toggle-in").onclick = OSRM.GUI.toggleMain;
|
document.getElementById("gui-toggle-in").onclick = OSRM.GUI.toggleMain;
|
||||||
document.getElementById("gui-toggle-out").onclick = OSRM.GUI.toggleMain;
|
document.getElementById("gui-toggle-out").onclick = OSRM.GUI.toggleMain;
|
||||||
document.getElementById("gui-printer").onclick = OSRM.Printing.print;
|
|
||||||
|
|
||||||
document.getElementById("gui-input-source").onchange = function() {OSRM.RoutingGUI.inputChanged(OSRM.C.SOURCE_LABEL);};
|
document.getElementById("gui-input-source").onchange = function() {OSRM.RoutingGUI.inputChanged(OSRM.C.SOURCE_LABEL);};
|
||||||
document.getElementById("gui-delete-source").onclick = function() {OSRM.RoutingGUI.deleteMarker(OSRM.C.SOURCE_LABEL);};
|
document.getElementById("gui-delete-source").onclick = function() {OSRM.RoutingGUI.deleteMarker(OSRM.C.SOURCE_LABEL);};
|
||||||
|
@ -90,6 +90,7 @@ onClick: function(e) {
|
|||||||
|
|
||||||
OSRM.Routing.getRoute();
|
OSRM.Routing.getRoute();
|
||||||
OSRM.G.markers.highlight.hide();
|
OSRM.G.markers.highlight.hide();
|
||||||
|
OSRM.G.markers.dragger.hide();
|
||||||
},
|
},
|
||||||
onDrag: function(e) {
|
onDrag: function(e) {
|
||||||
this.parent.setPosition( e.target.getLatLng() );
|
this.parent.setPosition( e.target.getLatLng() );
|
||||||
|
@ -54,32 +54,32 @@ OSRM.Localization["de"] = {
|
|||||||
"O": "Ost",
|
"O": "Ost",
|
||||||
"S": "Süden",
|
"S": "Süden",
|
||||||
"W": "Westen",
|
"W": "Westen",
|
||||||
"NO": "Nordost",
|
"NE": "Nordost",
|
||||||
"SO": "Südost",
|
"SE": "Südost",
|
||||||
"SW": "Südwest",
|
"SW": "Südwest",
|
||||||
"NW": "Nordwest",
|
"NW": "Nordwest",
|
||||||
// driving directions
|
// driving directions
|
||||||
"DIRECTION_0":"Unbekannte Anweisung[ auf <b>%s</b>]",
|
"DIRECTION_0":"Unbekannte Anweisung[ auf <b>%s</b>]",
|
||||||
"DIRECTION_1":"Links abbiegen[ auf <b>%s</b>]",
|
"DIRECTION_1":"Links abbiegen[ auf <b>%s</b>]",
|
||||||
"DIRECTION_2":"Rechts abbiegen[ auf <b>%s</b>]",
|
"DIRECTION_2":"Rechts abbiegen[ auf <b>%s</b>]",
|
||||||
"DIRECTION_3":"Umkehren[ auf <b>%s</b>]",
|
"DIRECTION_3":"Wenden[ auf <b>%s</b>]",
|
||||||
"DIRECTION_4":"Fahren Sie Richtung <b>%s</b>",
|
"DIRECTION_4":"Fahren Sie Richtung <b>%s</b>",
|
||||||
"DIRECTION_5":"Weiterfahren[ auf <b>%s</b>]",
|
"DIRECTION_5":"Geradeaus weiterfahren[ auf <b>%s</b>]",
|
||||||
"DIRECTION_6":"Leicht links abbiegen[ auf <b>%s</b>]",
|
"DIRECTION_6":"Leicht links abbiegen[ auf <b>%s</b>]",
|
||||||
"DIRECTION_7":"Leicht rechts abbiegen[ auf <b>%s</b>]",
|
"DIRECTION_7":"Leicht rechts abbiegen[ auf <b>%s</b>]",
|
||||||
"DIRECTION_8":"Scharf links abbiegen[ auf <b>%s</b>]",
|
"DIRECTION_8":"Scharf links abbiegen[ auf <b>%s</b>]",
|
||||||
"DIRECTION_9":"Scharf rechts abbiegen[ auf <b>%s</b>]",
|
"DIRECTION_9":"Scharf rechts abbiegen[ auf <b>%s</b>]",
|
||||||
"DIRECTION_10":"In den Kreisverkehr einfahren und bei erster Möglichkeit verlassen[ auf <b>%s</b>]",
|
"DIRECTION_10":"In den Kreisverkehr einfahren und bei erster Möglichkeit[ in Richtung <b>%s</b>] verlassen",
|
||||||
"DIRECTION_11":"In den Kreisverkehr einfahren und bei zweiter Möglichkeit verlassen[ auf <b>%s</b>]",
|
"DIRECTION_11":"In den Kreisverkehr einfahren und bei zweiter Möglichkeit[ in Richtung <b>%s</b>] verlassen",
|
||||||
"DIRECTION_12":"In den Kreisverkehr einfahren und bei dritter Möglichkeit verlassen[ auf <b>%s</b>]",
|
"DIRECTION_12":"In den Kreisverkehr einfahren und bei dritter Möglichkeit[ in Richtung <b>%s</b>] verlassen",
|
||||||
"DIRECTION_13":"In den Kreisverkehr einfahren und bei vierter Möglichkeit verlassen[ auf <b>%s</b>]",
|
"DIRECTION_13":"In den Kreisverkehr einfahren und bei vierter Möglichkeit[ in Richtung <b>%s</b>] verlassen",
|
||||||
"DIRECTION_14":"In den Kreisverkehr einfahren und bei fünfter Möglichkeit verlassen[ auf <b>%s</b>]",
|
"DIRECTION_14":"In den Kreisverkehr einfahren und bei fünfter Möglichkeit[ in Richtung <b>%s</b>] verlassen",
|
||||||
"DIRECTION_15":"In den Kreisverkehr einfahren und bei sechster Möglichkeit verlassen[ auf <b>%s</b>]",
|
"DIRECTION_15":"In den Kreisverkehr einfahren und bei sechster Möglichkeit[ in Richtung <b>%s</b>] verlassen",
|
||||||
"DIRECTION_16":"In den Kreisverkehr einfahren und bei siebter Möglichkeit verlassen[ auf <b>%s</b>]",
|
"DIRECTION_16":"In den Kreisverkehr einfahren und bei siebter Möglichkeit[ in Richtung <b>%s</b>] verlassen",
|
||||||
"DIRECTION_17":"In den Kreisverkehr einfahren und bei achter Möglichkeit verlassen[ auf <b>%s</b>]",
|
"DIRECTION_17":"In den Kreisverkehr einfahren und bei achter Möglichkeit[ in Richtung <b>%s</b>] verlassen",
|
||||||
"DIRECTION_18":"In den Kreisverkehr einfahren und bei neunter Möglichkeit verlassen[ auf <b>%s</b>]",
|
"DIRECTION_18":"In den Kreisverkehr einfahren und bei neunter Möglichkeit[ in Richtung <b>%s</b>] verlassen",
|
||||||
"DIRECTION_19":"In den Kreisverkehr einfahren und bei zehnter Möglichkeit verlassen[ auf <b>%s</b>]",
|
"DIRECTION_19":"In den Kreisverkehr einfahren und bei zehnter Möglichkeit[ in Richtung <b>%s</b>] verlassen",
|
||||||
"DIRECTION_20":"In den Kreisverkehr einfahren und bei einer der vielen Möglichkeiten verlassen[ auf <b>%s</b>]",
|
"DIRECTION_20":"In den Kreisverkehr einfahren und bei einer der vielen Möglichkeiten[ in Richtung <b>%s</b>] verlassen",
|
||||||
"DIRECTION_21":"Sie haben Ihr Ziel erreicht"
|
"DIRECTION_21":"Sie haben Ihr Ziel erreicht"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ init: function() {
|
|||||||
// perform language change
|
// perform language change
|
||||||
change: function(language) {
|
change: function(language) {
|
||||||
OSRM.DEFAULTS.LANGUAGE = language;
|
OSRM.DEFAULTS.LANGUAGE = language;
|
||||||
|
document.getElementById('gui-language-toggle').value = language;
|
||||||
if( OSRM.Localization[language]) {
|
if( OSRM.Localization[language]) {
|
||||||
OSRM.GUI.setLanguage();
|
OSRM.GUI.setLanguage();
|
||||||
if( OSRM.G.markers.route.length > 1)
|
if( OSRM.G.markers.route.length > 1)
|
||||||
|
@ -91,8 +91,6 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
<!-- header -->
|
<!-- header -->
|
||||||
<div id="input-mask-header">
|
<div id="input-mask-header">
|
||||||
<div id="gui-toggle-out" class="iconic-button top-right-button"></div>
|
<div id="gui-toggle-out" class="iconic-button top-right-button"></div>
|
||||||
<div class="quad top-right-button"></div>
|
|
||||||
<div id="gui-printer" class="iconic-button top-right-button"></div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- input mask -->
|
<!-- input mask -->
|
||||||
|
@ -27,6 +27,7 @@ OSRM.init = function() {
|
|||||||
OSRM.Localization.init();
|
OSRM.Localization.init();
|
||||||
OSRM.GUI.init();
|
OSRM.GUI.init();
|
||||||
OSRM.Map.init();
|
OSRM.Map.init();
|
||||||
|
OSRM.Printing.init();
|
||||||
OSRM.Routing.init();
|
OSRM.Routing.init();
|
||||||
|
|
||||||
// check if the URL contains some GET parameter, e.g. for showing a route
|
// check if the URL contains some GET parameter, e.g. for showing a route
|
||||||
@ -129,7 +130,15 @@ OSRM.checkURL = function(){
|
|||||||
if(name_val.length!=2)
|
if(name_val.length!=2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(name_val[0] == 'loc') {
|
if(name_val[0] == 'hl') {
|
||||||
|
for(var i=0, size=OSRM.Localization.supported_languages.length; i<size; i++) {
|
||||||
|
if( OSRM.Localization.supported_languages[i].encoding == name_val[1]) {
|
||||||
|
OSRM.Localization.change(name_val[1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(name_val[0] == 'loc') {
|
||||||
var coordinates = unescape(name_val[1]).split(',');
|
var coordinates = unescape(name_val[1]).split(',');
|
||||||
if(coordinates.length!=2 || !OSRM.Utils.isLatitude(coordinates[0]) || !OSRM.Utils.isLongitude(coordinates[1]) )
|
if(coordinates.length!=2 || !OSRM.Utils.isLatitude(coordinates[0]) || !OSRM.Utils.isLongitude(coordinates[1]) )
|
||||||
return;
|
return;
|
||||||
@ -159,7 +168,7 @@ OSRM.checkURL = function(){
|
|||||||
|
|
||||||
// case 1: destination given
|
// case 1: destination given
|
||||||
if( destination != undefined ) {
|
if( destination != undefined ) {
|
||||||
var index = OSRM.G.markers.setTarget( e.latlng );
|
var index = OSRM.G.markers.setTarget( destination.latlng );
|
||||||
if( destination_name == null )
|
if( destination_name == null )
|
||||||
OSRM.Geocoder.updateAddress( OSRM.C.TARGET_LABEL, OSRM.C.DO_FALLBACK_TO_LAT_LNG );
|
OSRM.Geocoder.updateAddress( OSRM.C.TARGET_LABEL, OSRM.C.DO_FALLBACK_TO_LAT_LNG );
|
||||||
else
|
else
|
||||||
@ -170,7 +179,7 @@ OSRM.checkURL = function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// case 2: locations given
|
// case 2: locations given
|
||||||
if( positions != []) {
|
if( positions.length > 0) {
|
||||||
// draw via points
|
// draw via points
|
||||||
if( positions.length > 0) {
|
if( positions.length > 0) {
|
||||||
OSRM.G.markers.setSource( positions[0] );
|
OSRM.G.markers.setSource( positions[0] );
|
||||||
@ -196,6 +205,8 @@ OSRM.checkURL = function(){
|
|||||||
// compute route
|
// compute route
|
||||||
OSRM.Routing.getRoute();
|
OSRM.Routing.getRoute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// default case: do nothing
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,6 +20,21 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
|
|
||||||
OSRM.Printing = {
|
OSRM.Printing = {
|
||||||
|
|
||||||
|
init: function() {
|
||||||
|
var icon = document.createElement('div');
|
||||||
|
icon.id = "gui-printer";
|
||||||
|
icon.className = "iconic-button top-right-button";
|
||||||
|
|
||||||
|
var spacer = document.createElement('div');
|
||||||
|
spacer.className = "quad top-right-button";
|
||||||
|
|
||||||
|
var input_mask_header = document.getElementById('input-mask-header');
|
||||||
|
input_mask_header.appendChild(spacer,input_mask_header.lastChild);
|
||||||
|
input_mask_header.appendChild(icon,input_mask_header.lastChild);
|
||||||
|
|
||||||
|
document.getElementById("gui-printer").onclick = OSRM.Printing.print;
|
||||||
|
},
|
||||||
|
|
||||||
windowLoaded: function(){
|
windowLoaded: function(){
|
||||||
OSRM.printwindow.initialize();
|
OSRM.printwindow.initialize();
|
||||||
OSRM.Printing.show( OSRM.G.response );
|
OSRM.Printing.show( OSRM.G.response );
|
||||||
|
@ -74,20 +74,12 @@ show: function(response) {
|
|||||||
|
|
||||||
// build route description
|
// build route description
|
||||||
if( i == 0 )
|
if( i == 0 )
|
||||||
route_desc += OSRM.loc("DIRECTION_"+OSRM.RoutingDescription.getDirectionId(response.route_instructions[i][0])).replace(/%s/, OSRM.loc(response.route_instructions[i][6]) );
|
route_desc += OSRM.loc("DIRECTION_"+OSRM.RoutingDescription.mapDirectionId(response.route_instructions[i][0])).replace(/%s/, OSRM.loc(response.route_instructions[i][6]) );
|
||||||
else if( response.route_instructions[i][1] != "" )
|
else if( response.route_instructions[i][1] != "" )
|
||||||
route_desc += OSRM.loc("DIRECTION_"+OSRM.RoutingDescription.getDirectionId(response.route_instructions[i][0])).replace(/\[(.*)\]/,"$1").replace(/%s/, response.route_instructions[i][1]);
|
route_desc += OSRM.loc("DIRECTION_"+OSRM.RoutingDescription.mapDirectionId(response.route_instructions[i][0])).replace(/\[(.*)\]/,"$1").replace(/%s/, response.route_instructions[i][1]);
|
||||||
else
|
else
|
||||||
route_desc += OSRM.loc("DIRECTION_"+OSRM.RoutingDescription.getDirectionId(response.route_instructions[i][0])).replace(/\[(.*)\]/,"");
|
route_desc += OSRM.loc("DIRECTION_"+OSRM.RoutingDescription.mapDirectionId(response.route_instructions[i][0])).replace(/\[(.*)\]/,"");
|
||||||
|
|
||||||
|
|
||||||
// route_desc += response.route_instructions[i][0];
|
|
||||||
// if( i == 0 )
|
|
||||||
// route_desc += ' ' + OSRM.loc( response.route_instructions[i][6] );
|
|
||||||
// if( response.route_instructions[i][1] != "" ) {
|
|
||||||
// route_desc += ' on ';
|
|
||||||
// route_desc += '<b>' + response.route_instructions[i][1] + '</b>';
|
|
||||||
// }
|
|
||||||
route_desc += '</div>';
|
route_desc += '</div>';
|
||||||
route_desc += "</td>";
|
route_desc += "</td>";
|
||||||
|
|
||||||
@ -155,41 +147,8 @@ showNA: function( display_text ) {
|
|||||||
document.getElementById('information-box').innerHTML = "<div class='no-results big-font'>"+display_text+"</div>";
|
document.getElementById('information-box').innerHTML = "<div class='no-results big-font'>"+display_text+"</div>";
|
||||||
},
|
},
|
||||||
|
|
||||||
// map driving instructions to icons
|
//map driving instruction ids to internal ids
|
||||||
// [TODO: language-safe implementation]
|
mapDirectionId: function(name) {
|
||||||
getDirectionIcon: function(name) {
|
|
||||||
var directions = {
|
|
||||||
"Turn left":"turn-left",
|
|
||||||
"Turn right":"turn-right",
|
|
||||||
"U-Turn":"u-turn",
|
|
||||||
"Head":"continue",
|
|
||||||
"Continue":"continue",
|
|
||||||
"Turn slight left":"slight-left",
|
|
||||||
"Turn slight right":"slight-right",
|
|
||||||
"Turn sharp left":"sharp-left",
|
|
||||||
"Turn sharp right":"sharp-right",
|
|
||||||
"Enter roundabout and leave at first exit":"round-about",
|
|
||||||
"Enter roundabout and leave at second exit":"round-about",
|
|
||||||
"Enter roundabout and leave at third exit":"round-about",
|
|
||||||
"Enter roundabout and leave at fourth exit":"round-about",
|
|
||||||
"Enter roundabout and leave at fifth exit":"round-about",
|
|
||||||
"Enter roundabout and leave at sixth exit":"round-about",
|
|
||||||
"Enter roundabout and leave at seventh exit":"round-about",
|
|
||||||
"Enter roundabout and leave at eighth exit":"round-about",
|
|
||||||
"Enter roundabout and leave at nineth exit":"round-about",
|
|
||||||
"Enter roundabout and leave at tenth exit":"round-about",
|
|
||||||
"Enter roundabout and leave at one of the too many exit":"round-about",
|
|
||||||
"You have reached your destination":"target"
|
|
||||||
};
|
|
||||||
|
|
||||||
if( directions[name] )
|
|
||||||
return directions[name];
|
|
||||||
else
|
|
||||||
return "default";
|
|
||||||
},
|
|
||||||
|
|
||||||
//map driving instructions to ids
|
|
||||||
getDirectionId: function(name) {
|
|
||||||
var directions = {
|
var directions = {
|
||||||
"Turn left":1,
|
"Turn left":1,
|
||||||
"Turn right":2,
|
"Turn right":2,
|
||||||
@ -217,7 +176,7 @@ getDirectionId: function(name) {
|
|||||||
if( directions[name] )
|
if( directions[name] )
|
||||||
return directions[name];
|
return directions[name];
|
||||||
else
|
else
|
||||||
return "default";
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user