jlacko / gmapsdistance

Interface Between R and Google Maps
GNU General Public License v3.0
2 stars 3 forks source link

Google API call failed; check your internet connection #3

Closed shahronak47 closed 1 year ago

shahronak47 commented 1 year ago

I am trying to use this package but seem to be missing something. I am not able to run any example from README file -

gmapsdistance(origin = "Washington+DC", destination = "New+York+City+NY", mode = "driving", key = key2)

Google API call failed; check your internet connection
[1] NA
results <- gmapsdistance(origin = c("Washington DC", "New York NY", "Seattle WA", "Miami FL"), 
                         destination = c("Washington DC", "New York NY", "Seattle WA", "Miami FL"), 
                         mode = "bicycling",
                         dep_date = "2022-05-31", # provided as string in ISO 8601 format
                          dep_time = "12:00:00", # provided as string in HH:MM:SS format
                          key = key2) 

Error in gmapsdistance(origin = c("Washington DC", "New York NY", "Seattle WA",  : 
  The departure time has to be some time in the future!

where key2 is my API key.

I don't what I am doing wrong.

jlacko commented 1 year ago

The first function call is correct (since v4.0 it is not required to use pluses for spaces, but doing so is not a problem).

I get the following result, which feels OK and makes me wonder about your internet connection - are you behind a firewall for example?

$Distance
[1] 361950

$Time
[1] 13957

$Status
[1] "OK"

The second call is more problematic, as it uses departure date in May 2022; this is illegal as the departure must be in the future. Consider amending the date from 2022 to 2023. For a bicycle trip in May 31st 2023 you should be receiving this matrix:

$Distance
              Washington DC New York NY Seattle WA Miami FL
Washington DC             0      388506    4716725  1920304
New York NY          385772           0    5227717  2305503
Seattle WA          4654050     5205337          0  5590586
Miami FL            1908047     2307309    5597451        0

$Time
              Washington DC New York NY Seattle WA Miami FL
Washington DC             0       76869     885541   353376
New York NY           76192           0     969665   429186
Seattle WA           872976      966338          0  1034524
Miami FL             350235      428387    1036538        0

$Status
              Washington DC New York NY Seattle WA Miami FL
Washington DC "OK"          "OK"        "OK"       "OK"    
New York NY   "OK"          "OK"        "OK"       "OK"    
Seattle WA    "OK"          "OK"        "OK"       "OK"    
Miami FL      "OK"          "OK"        "OK"       "OK"  
shahronak47 commented 1 year ago

Thank you for your quick response and for verifying that it works for you. I installed the latest version of the dependencies of this package (RCurl and XML) and restarted R and it started working.

jlacko commented 1 year ago

great to hear that, thanks for letting me know!