1

I need to find the travel time between a given point for which I know latitude and longitude values and a series of points contained in the column of a dataframe (for which I also know the longitude and the latitude). I used the following code line:

distances_driving <-gmapsdistance(origin = CZ10$API , destination = "49.9919662993+14.6579083484",mode = "driving")

CZ10 is my dataframe, API is the column containing the values needed in the format "longitude+latitude".

When running the code, I get the following error:

StartTag: invalid element name Error: 1: StartTag: invalid element name

What might cause this?

evan
  • 5,443
  • 2
  • 11
  • 20
vsh1996
  • 9
  • 2

1 Answers1

0

The below code is working on my end:

library("gmapsdistance")

set.api.key("MY_API_KEY")

dataframe <- data.frame("API" = c("50.9417965+10.6668388", "51.162085+10.994824"))

distances_driving <-gmapsdistance(origin = dataframe$API, destination = "49.9919662993+14.6579083484", mode = "driving")
distances_driving

Output:

$Time
                     or Time.49.9919662993+14.6579083484
1 50.9417965+10.6668388                            14935
2   51.162085+10.994824                            14969

$Distance
                     or Distance.49.9919662993+14.6579083484
1 50.9417965+10.6668388                               397894
2   51.162085+10.994824                               402047

$Status
                     or status.49.9919662993+14.6579083484
1 50.9417965+10.6668388                                 OK
2   51.162085+10.994824                                 OK

This means that the issue is likely in your dataframe. Make sure that it has valid coordinates and a valid format. Hope this helps!

evan
  • 5,443
  • 2
  • 11
  • 20