Ant*_*tex 10 r geolocation leaflet rcharts
我正在考虑rChart/LeafLet为我县的房屋销售创建一个闪亮的应用程序.在任何给定的时间有几百个房子待售.想要为所有人映射街道地址到地理位置(纬度/经度)并在地图上显示它们.所以,我正在寻找可以将街道地址映射到地理位置的ar包,服务或数据库.
chr*_*oph 20
这是一个基于哈维建议的功能.它将查找地址并给出第一个结果的坐标.看看x函数中的结构,看看你能得到的其他信息.
geocodeAdddress <- function(address) {
require(RJSONIO)
url <- "http://maps.google.com/maps/api/geocode/json?address="
url <- URLencode(paste(url, address, "&sensor=false", sep = ""))
x <- fromJSON(url, simplify = FALSE)
if (x$status == "OK") {
out <- c(x$results[[1]]$geometry$location$lng,
x$results[[1]]$geometry$location$lat)
} else {
out <- NA
}
Sys.sleep(0.2) # API only allows 5 requests per second
out
}
Run Code Online (Sandbox Code Playgroud)
例如:
R> geocodeAdddress("Time Square, New York City")
[1] -73.98722 40.7575
Run Code Online (Sandbox Code Playgroud)
我使用过 Google 地理定位,它设置简单,并且易于在几乎任何项目上实现:
https://developers.google.com/maps/documentation/geocoding/intro