michaeldorman / mapsapi

'sf'-Compatible Interface to Google Maps APIs
Other
50 stars 14 forks source link

Add language #16

Closed Agutierrez-nexbus closed 2 years ago

Agutierrez-nexbus commented 2 years ago

Is it possible to add a language parameter? According to the Google Routing API it is possible to specify the language in which to return the results.

michaeldorman commented 2 years ago

Thanks for the suggestion! Sure. I'll add this and get back to you as soon as possible.

michaeldorman commented 2 years ago

Now added language parameter in mp_directions. Please install the development version:

remotes::install_github("michaeldorman/mapsapi")

and try the example:

library(mapsapi)
key = readLines("key_google")

# Directions in Russian
doc = mp_directions(
  origin = "Beer-Sheva",
  destination = "Rehovot",
  language = "ru",
  key = key,
  quiet = TRUE
)
seg = mp_get_segments(doc)
seg$instructions[1]
## [1] "Направляйтесь на <b>север</b> по <b>Haim Nachman Bialik St</b> в сторону <b>Eli'ezer Ben Yehuda St</b>"

Let me know if you encounter any issues with this, thanks!