1

I'm trying to use the Google Places API via the Googleway package in R to search for certain businesses (for example, gyms) nearby a location coordinate. It's important that the results are returned ranked by distance to that point, so I'm using the optional parameter rankby="distance". According to the documentation, if I'm using rankby="distance", radius must not be included, and if I include a search_string then rankby will be ignored. Also, I must include one of keyword, name, or place_type. Here is a snippet of my code:

df_places <- google_places(rankby = "distance",
                           radar = FALSE,
                           keyword = "fitness", 
                           place_type = "gym",
                           location = c(lat, lon),
                           key = key)

lat and lon are variables specified beforehand, so those are fine. However I get this error message and can't figure out why:

Error in validateLocationSearch(location, search_string, radius, rankby,  : 
     you must specify a radius if only using a 'location' search

I think this is a flaw in the package, not my code, because if I specified a radius the rankby="distance" would be ignored, and I am already specifying both place type and keyword. My only idea here is that perhaps rankby="distance" is not available for a Nearby Search (aka 'location' search). However that means it wouldn't work for any search type, since the other two are radar search (which requires radius) and text search (which requires search_string).

Am I overlooking something or is this broken? Any help or ideas would be greatly appreciated!

Cary Shindell
  • 1,336
  • 8
  • 25
  • Thanks for reporting. I've made [an issue on the github page](https://github.com/SymbolixAU/googleway/issues/167) and will investigate – SymbolixAU Jun 27 '18 at 22:31
  • 1
    [this commit](https://github.com/SymbolixAU/googleway/commit/0e00d8d5a3a164985f0c13bed1ae7b19cc3c9d3f) in the dev version should fix your issue. Try installing with `devtools::install_github("SymbolixAU/googleway")` – SymbolixAU Jun 28 '18 at 04:31
  • thanks for the help! – Cary Shindell Jun 29 '18 at 15:29

0 Answers0