alternatives work - sort of
This commit is contained in:
@@ -65,10 +65,11 @@ showRoute: function(response) {
|
||||
OSRM.RoutingDescription.showNA( OSRM.loc("NO_ROUTE_FOUND") );
|
||||
OSRM.Routing._snapRoute();
|
||||
} else {
|
||||
OSRM.RoutingGeometry.show(response);
|
||||
OSRM.RoutingNoNames.show(response);
|
||||
OSRM.RoutingDescription.show(response);
|
||||
OSRM.RoutingAlternatives.prepare(response);
|
||||
OSRM.RoutingAlternatives.init(OSRM.G.response);
|
||||
OSRM.RoutingGeometry.show(OSRM.G.response);
|
||||
OSRM.RoutingNoNames.show(OSRM.G.response);
|
||||
OSRM.RoutingDescription.show(OSRM.G.response);
|
||||
OSRM.RoutingAlternatives._drawGUI();
|
||||
OSRM.Routing._snapRoute();
|
||||
}
|
||||
OSRM.Routing._updateHints(response);
|
||||
@@ -96,12 +97,11 @@ showRoute_Redraw: function(response) {
|
||||
if(!response)
|
||||
return;
|
||||
|
||||
//OSRM.G.response = response; // not needed, even harmful as important information is not stored!
|
||||
//OSRM.RoutingAlternatives.prepare_Redraw(response);
|
||||
OSRM.G.response = response; // not needed, even harmful as important information is not stored! ????
|
||||
if(response.status != 207) {
|
||||
OSRM.RoutingAlternatives.prepare_Redraw(response);
|
||||
OSRM.RoutingAlternatives.init(OSRM.G.response);
|
||||
OSRM.RoutingGeometry.show(OSRM.G.response);
|
||||
OSRM.RoutingNoNames.show(OSRM.Gresponse);
|
||||
OSRM.RoutingNoNames.show(OSRM.G.response);
|
||||
}
|
||||
OSRM.Routing._updateHints(response);
|
||||
},
|
||||
|
||||
@@ -30,6 +30,33 @@ _buttons: [
|
||||
],
|
||||
|
||||
|
||||
// reset stored values
|
||||
reset: function() {
|
||||
OSRM.G.active_alternative = 0;
|
||||
OSRM.G.alternative_count = 0;
|
||||
},
|
||||
|
||||
// restructure response data
|
||||
init: function(response) {
|
||||
// move best route to alternative array
|
||||
var the_response = OSRM.G.response;
|
||||
the_response.alternative_geometries.unshift( response.route_geometry );
|
||||
the_response.alternative_instructions.unshift( response.route_instructions );
|
||||
the_response.alternative_summaries.unshift( response.route_summary );
|
||||
|
||||
// update basic information
|
||||
OSRM.G.alternative_count = response.alternative_geometries.length;
|
||||
if( OSRM.G.active_alternative == undefined )
|
||||
OSRM.G.active_alternative = 0;
|
||||
if( OSRM.G.active_alternative > OSRM.G.alternative_count - 1 )
|
||||
OSRM.G.active_alternative = 0;
|
||||
|
||||
// switch data
|
||||
the_response.route_geometry = the_response.alternative_geometries[OSRM.G.active_alternative];
|
||||
the_response.route_instructions = the_response.alternative_instructions[OSRM.G.active_alternative];
|
||||
the_response.route_summary = the_response.alternative_summaries[OSRM.G.active_alternative];
|
||||
},
|
||||
|
||||
// prepare using alternatives
|
||||
prepare: function(response) {
|
||||
// store basic information
|
||||
|
||||
Reference in New Issue
Block a user