如何使用中文地址通过ggmap获取地理编码

how to use chinese address get geocoding by ggmap

我有一些中文地址可以进行地理编码。我很确定一旦它通过这样的代码工作

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

但不知何故现在它不再工作,抛出如下错误:

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

注意到消息显示:"language=en-EN",请问有没有把语言改成中文的参数?非常感谢。

PS。我已经将 R 语言环境设置为中国。

  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"

ggmap::geocde 似乎没有 'language' 参数。

但是,您可以使用我的 googleway 包,因为它确实公开了语言参数。

要使用它,您还需要 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"