'gmapsdistance report "1: StartTag: invalid element name" for some data point

I tried to use gmapsdistance to calculate the driving time between origin and destination in R. Both origin and destination adopt coordinates (latitude and longitude). The code looks like this:

distance <- as.data.frame(
gmapsdistance(
origin=df$origin,
destination=df$destination,
combinations = "pairwise",
mode="driving",
key = "My API Key",
traffic_model = "None"
))

It works well for some data points but reports following error for others.

Error in (function (cond)  : error in evaluating the argument 'x' in selecting a method for function 'as.data.frame': 1: StartTag: invalid element name 2: StartTag: invalid element name 3: StartTag: invalid element name 4: StartTag: invalid element name

I checked these data points using Google map, and I think they are some very normal addresses which are next to branch roads (cars are allowed to go through these roads).

I also tried to search the error on Stackoverflow, but most are related to XML instead of gmapdistance in R.

I am wondering if there is any solution for this problem. Thank you very much!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source