nextzen / lrm-mapzen

Support for Mapzen Turn-by-Turn routing in Leaflet Routing Machine
https://mapzen.com/projects/turn-by-turn/
Other
86 stars 31 forks source link

Change units to miles #27

Closed matbeard closed 8 years ago

matbeard commented 9 years ago

Hi.

Can you please tell me where to put the units: "miles" parameter in the L.Routing.control?

I've tried all sorts of options, but the route is still in kilometers.

Thank you

hanbyul-here commented 9 years ago

Now it is available via throwing parameter to Formatter like, formatter: new L.Routing.Valhalla.Formatter({units:'imperial'})

matbeard commented 9 years ago

Hi, I've tried without the unitNames parameter, as you suggested on the leaflet-routing-machine repo, but it doesn't seem to have any effect.

Am I right in thinking the json passed to Valhalla should include a units parameter with this setting? It isn't doing... this is an example of the json that's generated: {"locations":[{"lat":53.43753,"lon":-1.10557,"type":"break"},{"lat":53.5224,"lon":-1.1394,"type":"break"}],"costing":"auto"}

Any suggestions? Or am I missing something?

Thanks

dgearhart commented 9 years ago

If you want miles returned from Valhalla then you need to add directions_options":{"units":"miles"} to the request, for example: {"locations":[{"lat":53.43753,"lon":-1.10557,"type":"break"},{"lat":53.5224,"lon":-1.1394,"type":"break"}],"costing":"auto","directions_options":{"units":"miles"}}

kevinkreiser commented 9 years ago

If you are using the upstream, couldn't it be the case that the commits that added this feature aren't merged upstream? @hanbyul-here did you pr your changes back to upstream?

hanbyul-here commented 9 years ago

Yes, you can pass the unit option to Valhalla, but lrm-valhalla is currently not using that option. It just gets default value from Valhalla in km, and converts it with Formatter (It is planning to update to use all available options of Valhalla soon! ) I updated example of lrm-valhalla using miles on master branch, and npm side too. Please try this and let us know it works for you or not.