diff --git a/WebContent/OSRM.GUI.js b/WebContent/OSRM.GUI.js index 6d4c3841d..a1f780dec 100644 --- a/WebContent/OSRM.GUI.js +++ b/WebContent/OSRM.GUI.js @@ -44,12 +44,10 @@ init: function() { 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").onkeyup = function(e) {OSRM.RoutingGUI.keyUp(e,OSRM.C.SOURCE_LABEL);}; document.getElementById("gui-delete-source").onclick = function() {OSRM.RoutingGUI.deleteMarker(OSRM.C.SOURCE_LABEL);}; document.getElementById("gui-search-source").onclick = function() {OSRM.RoutingGUI.showMarker(OSRM.C.SOURCE_LABEL);}; document.getElementById("gui-input-target").onchange = function() {OSRM.RoutingGUI.inputChanged(OSRM.C.TARGET_LABEL);}; - document.getElementById("gui-input-target").onkeyup = function(e) {OSRM.RoutingGUI.keyUp(e,OSRM.C.TARGET_LABEL);}; document.getElementById("gui-delete-target").onclick = function() {OSRM.RoutingGUI.deleteMarker(OSRM.C.TARGET_LABEL);}; document.getElementById("gui-search-target").onclick = function() {OSRM.RoutingGUI.showMarker(OSRM.C.TARGET_LABEL);}; @@ -129,6 +127,12 @@ toggleOptions: function() { } else { document.getElementById('options-box').style.visibility="visible"; } +}, + +// clear output area +clearResults: function() { + document.getElementById('information-box').innerHTML = ""; + document.getElementById('information-box-header').innerHTML = ""; } }; diff --git a/WebContent/OSRM.Geocoder.js b/WebContent/OSRM.Geocoder.js index d02029e51..b81f2ef20 100644 --- a/WebContent/OSRM.Geocoder.js +++ b/WebContent/OSRM.Geocoder.js @@ -79,7 +79,7 @@ _showResults: function(response, parameters) { // show first result OSRM.Geocoder._onclickResult(parameters.marker_id, response[0].lat, response[0].lon); - if( OSRM.G.markers.route.length > 1 ) + if( OSRM.G.markers.route.length > 1 ) // if a route is displayed, we don't need to show other possible geocoding results return; // show possible results for input diff --git a/WebContent/OSRM.Markers.js b/WebContent/OSRM.Markers.js index a86e4853f..cdc30e2f5 100644 --- a/WebContent/OSRM.Markers.js +++ b/WebContent/OSRM.Markers.js @@ -109,7 +109,9 @@ onDragStart: function(e) { } if( this.parent != OSRM.G.markers.highlight) - OSRM.G.markers.highlight.hide(); + OSRM.G.markers.highlight.hide(); + if( this.parent != OSRM.G.markers.dragger) + OSRM.G.markers.dragger.hide(); if (OSRM.G.route.isShown()) OSRM.G.route.showOldRoute(); }, @@ -124,8 +126,7 @@ onDragEnd: function(e) { OSRM.G.route.hideUnnamedRoute(); } else { OSRM.Geocoder.updateAddress(this.parent.label); - document.getElementById('information-box').innerHTML = ""; // do we want this? - document.getElementById('information-box-header').innerHTML = ""; + OSRM.GUI.clearResults(); } }, toString: function() { diff --git a/WebContent/localization/OSRM.Locale.de.js b/WebContent/localization/OSRM.Locale.de.js index b0029cab0..7ba28b514 100644 --- a/WebContent/localization/OSRM.Locale.de.js +++ b/WebContent/localization/OSRM.Locale.de.js @@ -59,10 +59,11 @@ OSRM.Localization["de"] = { "SW": "Südwest", "NW": "Nordwest", // driving directions +"DIRECTION_0":"Unbekannte Anweisung[ auf %s]", "DIRECTION_1":"Links abbiegen[ auf %s]", "DIRECTION_2":"Rechts abbiegen[ auf %s]", "DIRECTION_3":"Umkehren[ auf %s]", -"DIRECTION_4":"Fahren Sie Richtung %s", +"DIRECTION_4":"Fahren Sie Richtung %s", "DIRECTION_5":"Weiterfahren[ auf %s]", "DIRECTION_6":"Leicht links abbiegen[ auf %s]", "DIRECTION_7":"Leicht rechts abbiegen[ auf %s]", @@ -72,7 +73,7 @@ OSRM.Localization["de"] = { "DIRECTION_11":"In den Kreisverkehr einfahren und bei zweiter Möglichkeit verlassen[ auf %s]", "DIRECTION_12":"In den Kreisverkehr einfahren und bei dritter Möglichkeit verlassen[ auf %s]", "DIRECTION_13":"In den Kreisverkehr einfahren und bei vierter Möglichkeit verlassen[ auf %s]", -"DIRECTION_14":"In den Kreisverkehr einfahren und bei f�nfter Möglichkeit verlassen[ auf %s]", +"DIRECTION_14":"In den Kreisverkehr einfahren und bei fünfter Möglichkeit verlassen[ auf %s]", "DIRECTION_15":"In den Kreisverkehr einfahren und bei sechster Möglichkeit verlassen[ auf %s]", "DIRECTION_16":"In den Kreisverkehr einfahren und bei siebter Möglichkeit verlassen[ auf %s]", "DIRECTION_17":"In den Kreisverkehr einfahren und bei achter Möglichkeit verlassen[ auf %s]", diff --git a/WebContent/localization/OSRM.Locale.en.js b/WebContent/localization/OSRM.Locale.en.js index a063d9fa5..86331ad33 100644 --- a/WebContent/localization/OSRM.Locale.en.js +++ b/WebContent/localization/OSRM.Locale.en.js @@ -59,10 +59,11 @@ OSRM.Localization["en"] = { "SW": "southwest", "NW": "northwest", // driving directions +"DIRECTION_0":"Unknown instruction[ on %s]", "DIRECTION_1":"Turn left[ on %s]", "DIRECTION_2":"Turn right[ on %s]", "DIRECTION_3":"U-Turn[ on %s]", -"DIRECTION_4":"Head %s", +"DIRECTION_4":"Head %s", "DIRECTION_5":"Continue[ on %s]", "DIRECTION_6":"Turn slight left[ on %s]", "DIRECTION_7":"Turn slight right[ on %s]", diff --git a/WebContent/localization/OSRM.Localization.js b/WebContent/localization/OSRM.Localization.js index 4063a619b..cc121b29f 100644 --- a/WebContent/localization/OSRM.Localization.js +++ b/WebContent/localization/OSRM.Localization.js @@ -30,6 +30,7 @@ init: function() { // create dropdown menu var select = document.createElement('select'); select.id = "gui-language-toggle"; + select.className = "top-left-button"; select.onchange = function() { OSRM.Localization.change(this.value); }; // fill dropdown menu @@ -67,7 +68,7 @@ change: function(language) { } else { var script = document.createElement('script'); script.type = 'text/javascript'; - script.src = "Localization/OSRM.Locale."+language+".js"; + script.src = "localization/OSRM.Locale."+language+".js"; document.head.appendChild(script); } }, diff --git a/WebContent/main.css b/WebContent/main.css index 3116951fe..02f695a1c 100644 --- a/WebContent/main.css +++ b/WebContent/main.css @@ -131,6 +131,10 @@ html, body { border: 0px; text-decoration:none; } +.top-left-button +{ + float:left; +} .top-right-button { float:right; diff --git a/WebContent/main.html b/WebContent/main.html index e6be48e39..b7af1bbc4 100644 --- a/WebContent/main.html +++ b/WebContent/main.html @@ -64,8 +64,8 @@ or see http://www.gnu.org/licenses/agpl.txt. - - + + diff --git a/WebContent/routing/OSRM.RoutingDescription.js b/WebContent/routing/OSRM.RoutingDescription.js index d632efca0..0fde40312 100644 --- a/WebContent/routing/OSRM.RoutingDescription.js +++ b/WebContent/routing/OSRM.RoutingDescription.js @@ -72,21 +72,22 @@ show: function(response) { route_desc += ''; route_desc += '
'; -// // build route description -// if( i == 0 ) -// route_desc += OSRM.loc("DIRECTION_"+response.route_instructions[i][0]).replace(/%s/, response.route_instructions[i][6]); -// else if( response.route_instructions[i][1] != "" ) -// route_desc += OSRM.loc("DIRECTION_"+response.route_instructions[i][0]).replace(/\[(.*)\]/,""); -// else -// route_desc += OSRM.loc("DIRECTION_"+response.route_instructions[i][0]).replace(/\[(.*)\]/,"$1").replace(/%s/, response.route_instructions[i][6]); - - route_desc += response.route_instructions[i][0]; + // build route description if( i == 0 ) - route_desc += ' ' + OSRM.loc( response.route_instructions[i][6] ); - if( response.route_instructions[i][1] != "" ) { - route_desc += ' on '; - route_desc += '' + response.route_instructions[i][1] + ''; - } + route_desc += OSRM.loc("DIRECTION_"+OSRM.RoutingDescription.getDirectionId(response.route_instructions[i][0])).replace(/%s/, OSRM.loc(response.route_instructions[i][6]) ); + 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]); + else + route_desc += OSRM.loc("DIRECTION_"+OSRM.RoutingDescription.getDirectionId(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 += '' + response.route_instructions[i][1] + ''; +// } route_desc += '
'; route_desc += ""; @@ -181,6 +182,38 @@ getDirectionIcon: function(name) { "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 = { + "Turn left":1, + "Turn right":2, + "U-Turn":3, + "Head":4, + "Continue":5, + "Turn slight left":6, + "Turn slight right":7, + "Turn sharp left":8, + "Turn sharp right":9, + "Enter roundabout and leave at first exit":10, + "Enter roundabout and leave at second exit":11, + "Enter roundabout and leave at third exit":12, + "Enter roundabout and leave at fourth exit":13, + "Enter roundabout and leave at fifth exit":14, + "Enter roundabout and leave at sixth exit":15, + "Enter roundabout and leave at seventh exit":16, + "Enter roundabout and leave at eighth exit":17, + "Enter roundabout and leave at nineth exit":18, + "Enter roundabout and leave at tenth exit":19, + "Enter roundabout and leave at one of the too many exit":20, + "You have reached your destination":21 + }; + if( directions[name] ) return directions[name]; else diff --git a/WebContent/routing/OSRM.RoutingGUI.js b/WebContent/routing/OSRM.RoutingGUI.js index b276ad1f3..f687fb49e 100644 --- a/WebContent/routing/OSRM.RoutingGUI.js +++ b/WebContent/routing/OSRM.RoutingGUI.js @@ -82,16 +82,6 @@ showMarker: function(marker_id) { OSRM.G.markers.route[OSRM.G.markers.route.length-1].centerView(); }, - -// keyup: force geocoder when enter is pressed -// (change event can be triggered, too; second call to geocoder gets fenced by JSONP) -// (alternative: track changes manually and only permit keyup event, if there was no change) -// do we want this? -keyUp: function(e, marker_id) { - if(e.keyCode==13) - OSRM.RoutingGUI.inputChanged(marker_id); -}, - // changed: any inputbox (is called when enter is pressed [after] or focus is lost [before]) inputChanged: function(marker_id) { if( marker_id == OSRM.C.SOURCE_LABEL)