有使用的空間我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
。
請參閱下面的解決方案,讓我知道如果你有任何問題。如果這可以爲您解決問題,請點擊複選標記,讓未來的讀者知道有一個解決方案。 –