]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/directions/mapquest.js
Merge remote-tracking branch 'openstreetmap/pull/954'
[rails.git] / app / assets / javascripts / index / directions / mapquest.js
index 2210664888e94b8062a9fe280322c9123f47754f..0f645ceeb7f35e621369d080517887f82154595d 100644 (file)
@@ -36,7 +36,7 @@ function MapQuestEngine(id, routeType) {
       var to = points[points.length - 1];
 
       return $.ajax({
-        url: document.location.protocol + "//open.mapquestapi.com/directions/v2/route",
+        url: document.location.protocol + OSM.MAPQUEST_DIRECTIONS_URL,
         data: {
           key: OSM.MAPQUEST_KEY,
           from: from.lat + "," + from.lng,
@@ -48,7 +48,7 @@ function MapQuestEngine(id, routeType) {
           generalize: 0,
           unit: "k"
         },
-        dataType: "json",
+        dataType: "jsonp",
         success: function (data) {
           if (data.info.statuscode !== 0)
             return callback(true);
@@ -83,12 +83,15 @@ function MapQuestEngine(id, routeType) {
             steps.push([L.latLng(s.startPoint.lat, s.startPoint.lng), d, s.narrative, s.distance * 1000, lineseg]);
           }
 
-          callback(null, {
+          callback(false, {
             line: line,
             steps: steps,
             distance: data.route.distance * 1000,
             time: data.route.time
           });
+        },
+        error: function () {
+          callback(true);
         }
       });
     }