/* 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 routing alternatives // [everything about handling alternatives] OSRM.RoutingAlternatives = { // remaining problems: how to handle PRINTING (do it internally), LINKS (add parameter to JSONP call) // data of gui buttons for alternativess _buttons: [ {id:"gui-a", label:"A"}, {id:"gui-b", label:"B"}, {id:"gui-c", label:"C"}, {id:"gui-d", label:"D"} ], // prepare using alternatives prepare: function(response) { // store basic information 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 == 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 ); the_response.alternative_summaries.unshift( response.route_summary ); // add alternative GUI OSRM.RoutingAlternatives._addGUI(); }, prepare_Redraw: function(response) { var original = {}; original.route_geometry = response.route_geometry; original.route_instructions = response.route_instructions; original.route_summary = response.route_summary; OSRM.G.response.alternatives = response.alternatives; OSRM.G.response.alternatives.push( original ); OSRM.RoutingAlternatives._addGUI(); }, // press one of the buttons press: function(button_id) { // switch active alternative OSRM.G.alternative_active = button_id; // redraw buttons var buttons = OSRM.RoutingAlternatives._buttons; for(var i=0, size=OSRM.G.alternative_count; i'+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