From: Richard Fairhurst Date: Wed, 22 Jan 2014 15:53:35 +0000 (+0000) Subject: Start MapQuest Open support X-Git-Tag: live~4242^2~56 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/c4f3d1bd32315abdcf057cae586bbf76eb6263b9?hp=7834c628e9088081fac0236f3f0aa6d22ff98452 Start MapQuest Open support --- diff --git a/app/assets/javascripts/routing_engines/cloudmade_foot.js b/app/assets/javascripts/routing_engines/cloudmade_foot.js index 3d047f8ab..149ceb31a 100644 --- a/app/assets/javascripts/routing_engines/cloudmade_foot.js +++ b/app/assets/javascripts/routing_engines/cloudmade_foot.js @@ -1,6 +1,7 @@ // CloudMade foot engine // *** again, this should be shared from a Cloudmade library somewhere // *** this API key is taken from some example code, not for real live use! +// http://cloudmade.com/documentation/routing OSM.RoutingEngines.list.push({ name: 'Foot (CloudMade)', @@ -16,7 +17,7 @@ OSM.RoutingEngines.list.push({ url+="/foot.js"; this.requestJSONP(url+"?callback="); }, - gotRoute: function(data) { + gotRoute: function(router,data) { console.log(data); // *** todo // *** will require some degree of refactoring because instruction text is pre-assembled diff --git a/app/assets/javascripts/routing_engines/mapquest_bicycle.js b/app/assets/javascripts/routing_engines/mapquest_bicycle.js new file mode 100644 index 000000000..123f2700a --- /dev/null +++ b/app/assets/javascripts/routing_engines/mapquest_bicycle.js @@ -0,0 +1,35 @@ +// see: +// http://developer.mapquest.com/web/products/open/directions-service +// http://open.mapquestapi.com/directions/ +// https://github.com/apmon/openstreetmap-website/blob/21edc353a4558006f0ce23f5ec3930be6a7d4c8b/app/controllers/routing_controller.rb#L153 + +// *** needs to give credit + +OSM.RoutingEngines.list.push({ + name: 'Bicycle (MapQuest Open)', + draggable: true, + _hints: {}, + getRoute: function(final,points) { + var url="http://open.mapquestapi.com/directions/v2/route?key=Fmjtd%7Cluur290anu%2Crl%3Do5-908a0y"; + var from=points[0]; var to=points[points.length-1]; + url+="&from="+from.join(','); + url+="&to="+to.join(','); + url+="&routeType=bicycle"; + url+="&manMaps=false"; + url+="&shapeFormat=raw&generalize=0"; + this.requestJSONP(url+"&callback="); + }, + gotRoute: function(router,data) { + var poly=[]; + var shape=data.route.shape.shapePoints; + for (var i=0; i