From 90c48abeafcc4519038927f42e13daea5c4bdaaa Mon Sep 17 00:00:00 2001 From: shiin Date: Wed, 20 Jun 2012 23:52:43 +0200 Subject: [PATCH] more alternative stuff --- WebContent/routing/OSRM.RoutingAlternatives.js | 10 +++++++--- WebContent/utils/OSRM.Utils.js | 9 +++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/WebContent/routing/OSRM.RoutingAlternatives.js b/WebContent/routing/OSRM.RoutingAlternatives.js index 64ab47fd8..68f5db5e2 100644 --- a/WebContent/routing/OSRM.RoutingAlternatives.js +++ b/WebContent/routing/OSRM.RoutingAlternatives.js @@ -35,14 +35,15 @@ _buttons: [ // prepare using alternatives prepare: function(response) { // store basic information - OSRM.G.alternative_count = response.alternative_geometries.length; + OSRM.G.alternative_count = response.alternative_geometries.length + 1; OSRM.G.alternative_active = 0; // do nothing if there is no alternative - if( OSRM.G.alternative_count == 0 ) + if( OSRM.G.alternative_count == 1 ) return; // move best route to alternative array + console.log("prepare"); var the_response = OSRM.G.response; the_response.alternative_geometries.unshift( response.route_geometry ); the_response.alternative_instructions.unshift( response.route_instructions ); @@ -86,12 +87,13 @@ _click: function(button_id) { var the_response = OSRM.G.response; the_response.route_geometry = the_response.alternative_geometries[button_id]; the_response.route_instructions = the_response.alternative_instructions[button_id]; - the_response.alternative_summaries = the_response.alternative_summaries[button_id]; + the_response.route_summary = the_response.alternative_summaries[button_id]; // show alternative OSRM.RoutingGeometry.show(the_response); OSRM.RoutingNoNames.show(the_response); OSRM.RoutingDescription.show(the_response); + OSRM.RoutingAlternatives._addGUI(); }, _mouseover: function(button_id) { console.log("over "+button_id); @@ -118,6 +120,8 @@ _addGUI: function() { var tooltip = OSRM.loc("DISTANCE")+":"+distance+" "+OSRM.loc("DURATION")+":"+time; var data = ''+buttons[i].label+''; document.getElementById('information-box-header').innerHTML = data + document.getElementById('information-box-header').innerHTML; + } + for(var i=0, size=OSRM.G.alternative_count; i