更新时间:2023-02-01 22:46:43
邮编本身可能含糊不清.如果您在搜索字符串中包含美国",则可以使用
It could be that the zip code on its own is ambiguous. If you include 'USA' in the search string it works
library(ggmap)
mapdist(from = c("19111, USA"), to = c("19187, USA"))
# from to m km miles seconds minutes hours
# 1 19111, USA 19187, USA 21420 21.42 13.31039 1976 32.93333 0.5488889
或
library(googleway)
set_key("your_api_key")
google_distance(origins = c("19111, USA"),
destinations = c("19187, USA"))
# $destination_addresses
# [1] "Philadelphia, PA 19187, USA"
#
# $origin_addresses
# [1] "Philadelphia, PA 19111, USA"
#
# $rows
# elements
# 1 21.4 km, 21420, 33 mins, 1976, 35 mins, 2101, OK
#
# $status
# [1] "OK"