]> git.openstreetmap.org Git - rails.git/blob - app/assets/javascripts/routing_engines/mapquest_bicycle.js
Move more engine-specific stuff out of main .js
[rails.git] / app / assets / javascripts / routing_engines / mapquest_bicycle.js
1 // see: 
2 // http://developer.mapquest.com/web/products/open/directions-service
3 // http://open.mapquestapi.com/directions/
4 // https://github.com/apmon/openstreetmap-website/blob/21edc353a4558006f0ce23f5ec3930be6a7d4c8b/app/controllers/routing_controller.rb#L153
5
6 // *** needs to give credit
7
8 OSM.RoutingEngines.list.push({
9         name: 'Bicycle (MapQuest Open)',
10         draggable: true,
11         _hints: {},
12         getRoute: function(final,points) {
13                 var url="http://open.mapquestapi.com/directions/v2/route?key=Fmjtd%7Cluur290anu%2Crl%3Do5-908a0y";
14                 var from=points[0]; var to=points[points.length-1];
15                 url+="&from="+from.join(',');
16                 url+="&to="+to.join(',');
17                 url+="&routeType=bicycle";
18                 url+="&manMaps=false";
19                 url+="&shapeFormat=raw&generalize=0";
20                 this.requestJSONP(url+"&callback=");
21         },
22         gotRoute: function(router,data) {
23                 var poly=[];
24                 var shape=data.route.shape.shapePoints;
25                 for (var i=0; i<shape.length; i+=2) {
26                         poly.push(L.latLng(shape[i],shape[i+1]));
27                 }
28                 router.setPolyline(poly);
29
30                 // data.shape.maneuverIndexes links turns to polyline positions
31                 // data.legs[0].maneuvers is list of turns
32                 console.log(data);
33 //              router.setItinerary(data.route_instructions);
34         }
35 });