]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/routing_engines/osrm.js
Merge pull request #19 from apmon/jsroute2
[rails.git] / app / assets / javascripts / routing_engines / osrm.js
index d6f3535b4fa945bfdabe655758adbf94f21669b2..b40d5b3069325ad757dbc853a729f84a6bcaea14 100644 (file)
@@ -13,7 +13,7 @@ OSRMEngine.prototype.createConfig = function() {
     var that = this;
     return {
         name: "javascripts.directions.engines.osrm_"+this.vehicleName.toLowerCase(),
-        creditline: 'Directions courtesy of <a href="http://project-osrm.org/" target="_blank">OSRM</a>',
+            creditline: '<a href="http://project-osrm.org/" target="_blank">OSRM</a>',
         draggable: true,
         _hints: {},
         getRoute: function(isFinal,points) {
@@ -38,12 +38,18 @@ OSRMEngine.prototype.createConfig = function() {
             var steps=[];
             for (i=0; i<data.route_instructions.length; i++) {
                 var s=data.route_instructions[i];
+                var linesegend;
                 var instCodes=s[0].split('-');
                 var instText="<b>"+(i+1)+".</b> ";
                 instText+=TURN_INSTRUCTIONS[instCodes[0]];
                 if (instCodes[1]) { instText+="exit "+instCodes[1]+" "; }
                 if (instCodes[0]!=15) { instText+=s[1] ? "<b>"+s[1]+"</b>" : I18n.t('javascripts.directions.instructions.unnamed'); }
-                steps.push([line[s[3]], s[0].split('-')[0], instText, s[2]]);
+                if ((i+1)<data.route_instructions.length) {
+                    linesegend = data.route_instructions[i+1][3] + 1;
+                } else {
+                    linesegend = s[3] + 1;
+                }
+                steps.push([line[s[3]], s[0].split('-')[0], instText, s[2], line.slice(s[3], linesegend)]);
             }
             if (steps.length) router.setItinerary({ steps: steps, distance: data.route_summary.total_distance, time: data.route_summary.total_time });
             return true;
@@ -51,4 +57,4 @@ OSRMEngine.prototype.createConfig = function() {
     };
 };
 
-OSM.RoutingEngines.list.push(new OSRMEngine("Car", "http://router.project-osrm.org/viaroute").createConfig());
+OSM.RoutingEngines.add(false, new OSRMEngine("Car", "http://router.project-osrm.org/viaroute").createConfig());