Start MapQuest Open support
This commit is contained in:
parent
7834c628e9
commit
c4f3d1bd32
2 changed files with 37 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
// CloudMade foot engine
|
// CloudMade foot engine
|
||||||
// *** again, this should be shared from a Cloudmade library somewhere
|
// *** again, this should be shared from a Cloudmade library somewhere
|
||||||
// *** this API key is taken from some example code, not for real live use!
|
// *** this API key is taken from some example code, not for real live use!
|
||||||
|
// http://cloudmade.com/documentation/routing
|
||||||
|
|
||||||
OSM.RoutingEngines.list.push({
|
OSM.RoutingEngines.list.push({
|
||||||
name: 'Foot (CloudMade)',
|
name: 'Foot (CloudMade)',
|
||||||
|
@ -16,7 +17,7 @@ OSM.RoutingEngines.list.push({
|
||||||
url+="/foot.js";
|
url+="/foot.js";
|
||||||
this.requestJSONP(url+"?callback=");
|
this.requestJSONP(url+"?callback=");
|
||||||
},
|
},
|
||||||
gotRoute: function(data) {
|
gotRoute: function(router,data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
// *** todo
|
// *** todo
|
||||||
// *** will require some degree of refactoring because instruction text is pre-assembled
|
// *** will require some degree of refactoring because instruction text is pre-assembled
|
||||||
|
|
35
app/assets/javascripts/routing_engines/mapquest_bicycle.js
Normal file
35
app/assets/javascripts/routing_engines/mapquest_bicycle.js
Normal file
|
@ -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<shape.length; i+=2) {
|
||||||
|
poly.push(L.latLng(shape[i],shape[i+1]));
|
||||||
|
}
|
||||||
|
router.setPolyline(poly);
|
||||||
|
|
||||||
|
// data.shape.maneuverIndexes links turns to polyline positions
|
||||||
|
// data.legs[0].maneuvers is list of turns
|
||||||
|
console.log(data);
|
||||||
|
// router.setItinerary(data.route_instructions);
|
||||||
|
}
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue