]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/routing_engines/osrm.js
Add distance/time summary
[rails.git] / app / assets / javascripts / routing_engines / osrm.js
index 4122a0b4d73ecf52fbad0b1d1e4e2264a7796c54..041f456f0ba9c6a474d42232d3f072149e12d82a 100644 (file)
@@ -24,7 +24,7 @@ OSRMEngine.prototype.createConfig = function() {
                                if (this._hints[pair]) url+= "&hint="+this._hints[pair];
                        }
                        if (isFinal) url+="&instructions=true";
-                       this.requestJSONP(url+"&jsonp=");
+                       this.requestCORS(url);
                },
                gotRoute: function(router,data) {
                        if (data.status==207) {
@@ -46,7 +46,7 @@ OSRMEngine.prototype.createConfig = function() {
                                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 (steps.length) router.setItinerary({ steps: steps });
+                       if (steps.length) router.setItinerary({ steps: steps, distance: data.route_summary.total_distance, time: data.route_summary.total_time });
                        return true;
                }
        };