简体   繁体   中英

how to use chinese address get geocoding by ggmap

I have some Chinese addresses to get geocode. I'm pretty sure once it worked by codes like this

geocode("黎明侨村",source = "google")

but somehow now it doesn't work at more, which throws error like:

 http://maps.googleapis.com/maps/api/staticmap?center=wenzhou&zoom=13&size=640x640&scale=2&maptype=roadmap&language=en-EN&sensor=false 

Noted the message shows :"language=en-EN",I wonder is there a parameter to change the language to Chinese? Many thanks.

PS. I've already set R locale to china.

  Sys.getlocale()

[1] "LC_COLLATE=Chinese (Simplified)_China.936;LC_CTYPE=Chinese (Simplified)_China.936;LC_MONETARY=Chinese (Simplified)_China.936;LC_NUMERIC=C;LC_TIME=Chinese (Simplified)_China.936"

There doesn't appear to be a 'language' argument for ggmap::geocde .

However, you can use my googleway package as it does expose the language argument.

To use it, you will also need a Google Maps Geocode API key

library(googleway)

## your api key goes here
api_key <- ""
google_geocode(address = "黎明侨村", language = "CN", key = api_key)


# $results
# address_components
# 1 Chezhan Avenue, Lucheng, Wenzhou, Zhejiang, China, 325003, Chezhan Ave, Lucheng, Wenzhou, Zhejiang, CN, 325003, route, political, sublocality, sublocality_level_1, locality, political, administrative_area_level_1, political, country, political, postal_code
# formatted_address geometry.location.lat geometry.location.lng
# 1 China, Zhejiang, Wenzhou, Lucheng, Chezhan Ave, 黎明侨村巷第86号 邮政编码: 325003              28.01603              120.6839
# geometry.location_type geometry.viewport.northeast.lat geometry.viewport.northeast.lng geometry.viewport.southwest.lat
# 1            APPROXIMATE                        28.01738                        120.6852                        28.01468
# geometry.viewport.southwest.lng                    place_id                            types
# 1                        120.6825 ChIJtSTHeutkTzQRafAmWKVXhaI establishment, point_of_interest
# 
# $status
# [1] "OK"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM