-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Miles or km #75
Comments
It would be great to offer something like that. I mean the core of the plugin uses the metric system. I digged up in the code and in routes_control.js and i noticed that after a successful response is received from the map-directions api , the corresponding routes are used to fill the information in the container with classs "mapbox-directions-routes". This container is filled with an unorder list , with routes being the list items. Every list item is filled with route details (duration , distance , etc). //using only a part of the code
directions.on('load', function (e) {
container.html('');
var routes = container.append('ul')
.selectAll('li')
.data(e.routes)
.enter().append('li')
.attr('class', 'mapbox-directions-route');
routes.append('div')
.attr('class','mapbox-directions-route-heading')
.text(function (route) { return 'Route ' + (e.routes.indexOf(route) + 1); });
routes.append('div')
.attr('class', 'mapbox-directions-route-summary')
.text(function (route) { return route.summary; });
//here come the miles!!!!!!!!
routes.append('div')
.attr('class', 'mapbox-directions-route-details')
.text(function (route) { return format.imperial(route.distance) + ', ' + format.duration(route.duration); }); routes.distance is on meters and the routes-control converts them to miles so it could be done i guess. var directions = L.mapbox.directions(system: 'metric') ; and it could be interpolated on the corresponding line ,
I am gonna try this tomorrow but i am not sure that would be wise because i may have missed so many things in the code , that it could mess it up. For my project , if this doesn't work i am gonna try something else: Btw the information in meters is right there for us: //lets say you have initialized a mydirections object
mydirections = L.mapbox.directions();
//after a route has been retrieved and drawn
//the distance in meters is available
// lets say there is only one route availble(route[0])
console.log(mydirections.directions.routes[0].distance);
//tadummmmm in meters |
@thanosbellos If you want to make a PR, that would be great. How about |
Off course!! I have just started implementing the idea. I hope i 'll soon have it right. |
Proposed an implementation on pull request #78 . I hope it helps !!! |
Congratulation having bicycle navigation now.
I was testing the bicycle route on your release page/map
https://www.mapbox.com/blog/bicycle-directions/
However as an bicyclist from a country (Denmark) which use km as standard - I would like to see km as part of the route description and not mention route description in miles when doing a A-B query.
Can this be fixed with language detection like "de, da, fi , fr, es" etc" would go to a km version and for other languages using miles goes to another version?
The text was updated successfully, but these errors were encountered: