It's up to you what you do with the question. You can answer it youself if you want. I probably won't add an answer because I think we've covered everything in this chat and I don't really have time to write it up
The result test you get from Goolge gives the driving instructions for the entire route. But it's split into legs. In this example there are 5 legs. And each leg has a distance & time.
yes I know what you're trying to do. However, to generate the map, you need to have the result of the google_directions() function, which you have assigned to df using the code df <- google_directions(...).
you inserted the object df1 (with the 1). I need to see df because the error you're getting is in this line - direction_polyline(df) - so I need to know what df looks like.
In your original question you create df with this line: df <- google_directions(...). What does this df look like? does the google_directions() funciton return anything and is df valid?
@RonakShah Have we just been answering the same question, but asked from different angles - https://stackoverflow.com/questions/59349487/is-there-a-faster-rewrite-to-deal-with-missing-xml-attributes & - https://stackoverflow.com/questions/59349700/is-there-a-way-to-handle-the-first-lapply-element-differently-or-prepend-it-to