Closed matbeard closed 8 years ago
Now it is available via throwing parameter to Formatter like,
formatter: new L.Routing.Valhalla.Formatter({units:'imperial'})
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
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"}}
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?
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.
Hi.
Can you please tell me where to put the
units: "miles"
parameter in theL.Routing.control
?I've tried all sorts of options, but the route is still in kilometers.
Thank you