SymbolixAU / googleway

R Package for accessing and plotting Google Maps
http://symbolixau.github.io/googleway/
Other
234 stars 46 forks source link

google_geocode function problem (bug?) #187

Closed dknykrisztina closed 4 years ago

dknykrisztina commented 6 years ago

Hy, I´d tested this simple, short code before I get it through the whole address list, but it had got en error.

Script: library(googleway) key <- "my_key" df <- google_geocode(address = "5 Rue J-F Kennedy 8332 Luxembourg", key = key, simplify = TRUE)

Error in value[3L] : There was an error downloading results. Please manually check the following URL is valid by entering it into a browswer. If valid, please file a bug report citing this URL: https://maps.googleapis.com/maps/api/geocode/json?&address=5+rue+j-f+kennedy+8332+luxembourg&key=

I tested in Firefox and Internet Explorer with the URL, and it was fine: { "results" : [ { "address_components" : [ { "long_name" : "5", "short_name" : "5", "types" : [ "street_number" ] }, { "long_name" : "Rue J-F Kennedy", "short_name" : "Rue J-F Kennedy", "types" : [ "route" ] }, { "long_name" : "Olm", "short_name" : "Olm", "types" : [ "locality", "political" ] }, { "long_name" : "Capellen", "short_name" : "Capellen", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "District de Luxembourg", "short_name" : "District de Luxembourg", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "Luxembourg", "short_name" : "LU", "types" : [ "country", "political" ] }, { "long_name" : "8332", "short_name" : "8332", "types" : [ "postal_code" ] } ], "formatted_address" : "5 Rue J-F Kennedy, 8332 Olm, Luxembourg", "geometry" : { "location" : { "lat" : 49.6480276, "lng" : 5.9942782 }, "location_type" : "ROOFTOP", "viewport" : { "northeast" : { "lat" : 49.6493765802915, "lng" : 5.995627180291502 }, "southwest" : { "lat" : 49.6466786197085, "lng" : 5.992929219708498 } } }, "place_id" : "ChIJkR_lV8VMlUcRSUmeVhgUxV0", "plus_code" : { "compound_code" : "JXXV+6P Mamer, Luxembourg", "global_code" : "8FX7JXXV+6P" }, "types" : [ "street_address" ] } ], "status" : "OK" }

If somebody can help my, I´d appriciate it. Thnx, Krisztina

SymbolixAU commented 5 years ago

I can't reproduce your error

library(googleway)
# key <- "my_key"
df <- google_geocode(address = "5 Rue J-F Kennedy 8332 Luxembourg", key = key, simplify = TRUE)

df$results$geometry$location
#        lat      lng
# 1 49.62014 6.146283

df$results$address_components
# [[1]]
#                long_name             short_name                                  types
# 1                      5                      5                          street_number
# 2 Avenue John F. Kennedy Avenue John F. Kennedy                                  route
# 3             Luxembourg             Luxembourg                    locality, political
# 4             Luxembourg             Luxembourg administrative_area_level_2, political
# 5 District de Luxembourg District de Luxembourg administrative_area_level_1, political
# 6             Luxembourg                     LU                     country, political
# 7                   1229                   1229                            postal_code

Are you behind a firewall, or on a company or uni network?

dknykrisztina commented 5 years ago

Yes, I´m working from a company server. Maybe the problem is in the proxy settings?

SymbolixAU commented 5 years ago

yeah - see these similar issues

SymbolixAU commented 5 years ago

@dknykrisztina did any of those links solve your issue?

jzadra commented 5 years ago

I have this problem also. It is not reproducible - the next attempt works. I am not using a proxy.

dcooley commented 5 years ago

@jzadra

the next attempt works

The next attempt on the same address, or a different address?

jzadra commented 5 years ago

Same address.

dcooley commented 5 years ago

This is really hard to debug without a reproducible example. The fact it works sometimes for you suggests to me it's not an issue with googleway. Have you searched for similar issues when using the geocoding API direct from Google?

sayac007 commented 3 years ago

It can be that the real address line you send to Google from R contains some invalid letters/characters, e.g. some French letters. Check the address for any symbols not contained in UTF-8 using this function: validUTF8(yorstring) If the result is "FALSE", replace invalid characters e.g. using gsub. To see which characters are invalid, use something like this: iconv(yorstring, "UTF-8", "UTF-8",sub="")

emilyluckey commented 3 years ago

It can be that the real address line you send to Google from R contains some invalid letters/characters, e.g. some French letters. Check the address for any symbols not contained in UTF-8 using this function: validUTF8(yorstring) If the result is "FALSE", replace invalid characters e.g. using gsub. To see which characters are invalid, use something like this: iconv(yorstring, "UTF-8", "UTF-8",sub="")

It works! I just try to change my address to UTF-8 by enc2utf8() . Thank you very much❤️❤️

(BTW I used an address from Taiwan in Traditional Chinese, hope the info could be helpful. )