有使用的空间我googleway
包没有问题
library(googleway)
apiKey <- 'your_api_key'
google_distance(origins = list("PAWTUCKET+LOWELL+MA"),
destinations = list("INDUSTRIAL WAY+SALEM+NH"),
mode = "driving",
key = apiKey)
# $destination_addresses
# [1] "Industrial Way, Salem, NH 03079, USA"
#
# $origin_addresses
# [1] "Pawtucket Blvd, Lowell, MA 01854, USA"
#
# $rows
# elements
# 1 23.2 km, 23150, 27 mins, 1648, 27 mins, 1605, OK
#
# $status
# [1] "OK"
说了这么多,和哈克-R在他们的回答提到了,因为你必须在一个空间出现实际错误的destination
(“INDUSTRIAL WAY + SALEM + NH”)。将其替换为+
,它将起作用。
gmapsdistance(origin = "PAWTUCKET+LOWELL+MA",
destination = "INDUSTRIAL+WAY+SALEM+NH",
combinations = "all",
mode = "driving",
key = 'api_key')
$Time
[1] 1591
$Distance
[1] 23150
$Status
[1] "OK"
从文档?gmapsdistance
If more than one word for a same location is used, they should be separated by a plus sign e.g. "Bogota+Colombia"
实际的错误来源于XML
包,其发动机罩下使用的gmapsdistance
。
请参阅下面的解决方案,让我知道如果你有任何问题。如果这可以为您解决问题,请点击复选标记,让未来的读者知道有一个解决方案。 –