]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/routing_engines/mapquest.js
Add distance/time summary
[rails.git] / app / assets / javascripts / routing_engines / mapquest.js
index f31a84458e43ef0c280d6f1dd105345061eab92f..3e6e0c3fc8ffc479fe0600e37ba54a53379562f4 100644 (file)
@@ -47,11 +47,11 @@ MapQuestEngine.prototype.createConfig = function() {
                        url+="&"+that.vehicleParam;
                        //url+="&locale=" + I18n.currentLocale(); //Doesn't actually work. MapQuest requires full locale e.g. "de_DE", but I18n only provides language, e.g. "de"
                        url+="&manMaps=false";
-                       url+="&shapeFormat=raw&generalize=0";
-                       this.requestJSONP(url+"&callback=");
+                       url+="&shapeFormat=raw&generalize=0&unit=k";
+                       this.requestCORS(url);
                },
                gotRoute: function(router,data) {
-                       // *** what if no route?
+                       if (data.info.statuscode!=0) return false;
                
                        var poly=[];
                        var shape=data.route.shape.shapePoints;
@@ -69,7 +69,7 @@ MapQuestEngine.prototype.createConfig = function() {
                                var d=(i==mq.length-1) ? 15: this.MQ_SPRITE_MAP[s.turnType];
                                steps.push([L.latLng(s.startPoint.lat, s.startPoint.lng), d, s.narrative, s.distance*1000]);
                        }
-                       router.setItinerary( { steps: steps });
+                       router.setItinerary( { steps: steps, distance: data.route.distance*1000, time: data.route['time'] });
                        return true;
                }
        };