X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/250bb47cc2723c7af6fac0a6e9e900c1a50f9292..037585db3933a2954b43bd4b30ea5e30ade00be2:/app/assets/javascripts/index/directions/mapquest.js diff --git a/app/assets/javascripts/index/directions/mapquest.js b/app/assets/javascripts/index/directions/mapquest.js index 935a1ca4c..fbbc55a5f 100644 --- a/app/assets/javascripts/index/directions/mapquest.js +++ b/app/assets/javascripts/index/directions/mapquest.js @@ -28,7 +28,7 @@ function MapQuestEngine(id, vehicleParam) { return { id: id, - creditline: 'MapQuest ', + creditline: 'MapQuest ', draggable: false, getRoute: function (points, callback) { @@ -42,15 +42,16 @@ function MapQuestEngine(id, vehicleParam) { url += "&manMaps=false"; url += "&shapeFormat=raw&generalize=0&unit=k"; - $.ajax({ + return $.ajax({ url: url, success: function (data) { - if (data.info.statuscode != 0) + if (data.info.statuscode !== 0) return callback(true); + var i; var line = []; var shape = data.route.shape.shapePoints; - for (var i = 0; i < shape.length; i += 2) { + for (i = 0; i < shape.length; i += 2) { line.push(L.latLng(shape[i], shape[i + 1])); } @@ -58,12 +59,12 @@ function MapQuestEngine(id, vehicleParam) { // data.route.legs[0].maneuvers is list of turns var steps = []; var mq = data.route.legs[0].maneuvers; - for (var i = 0; i < mq.length; i++) { + for (i = 0; i < mq.length; i++) { var s = mq[i]; var d; var linesegstart, linesegend, lineseg; linesegstart = data.route.shape.maneuverIndexes[i]; - if (i == mq.length - 1) { + if (i === mq.length - 1) { d = 15; linesegend = linesegstart + 1; } else { @@ -81,7 +82,7 @@ function MapQuestEngine(id, vehicleParam) { line: line, steps: steps, distance: data.route.distance * 1000, - time: data.route['time'] + time: data.route.time }); } }); @@ -89,6 +90,6 @@ function MapQuestEngine(id, vehicleParam) { }; } -OSM.Directions.addEngine(MapQuestEngine("mapquest_bicycle", "routeType=bicycle"), true); -OSM.Directions.addEngine(MapQuestEngine("mapquest_foot", "routeType=pedestrian"), true); -OSM.Directions.addEngine(MapQuestEngine("mapquest_car", "routeType=fastest"), true); +OSM.Directions.addEngine(new MapQuestEngine("mapquest_bicycle", "routeType=bicycle"), true); +OSM.Directions.addEngine(new MapQuestEngine("mapquest_foot", "routeType=pedestrian"), true); +OSM.Directions.addEngine(new MapQuestEngine("mapquest_car", "routeType=fastest"), true);