【发布时间】:2014-01-15 08:17:56
【问题描述】:
我有一个带有 lat/long 标记的 MongoDB 数据库,我需要另一个包含城市或区域级别边界的数据库(或其他解决方案)。如果在 Geojson 多边形中它会是最佳的。
我有一个名为 city 的字段(例如 'city' : 'New York'),但我想缩小到城市的区域/社区级别,例如“苏荷”。以这种方式解决问题的想法是基于谷歌的新地图。如果我们输入区域或邮政编码,我们会看到该区域的红点多边形。
我看到了Maxmind's 数据库,但它没有每个城市的边界。
到目前为止,我最好的解决方案是使用Google's Geocoding API,它返回一个框的边界:
例如对于:http://maps.googleapis.com/maps/api/geocode/json?address=soho&sensor=false
结果:
{
"results" : [
{
"address_components" : [
{
"long_name" : "SoHo",
"short_name" : "SoHo",
"types" : [ "neighborhood", "political" ]
},
{
"long_name" : "Manhattan",
"short_name" : "Manhattan",
"types" : [ "sublocality", "political" ]
},
{
"long_name" : "New York",
"short_name" : "New York",
"types" : [ "locality", "political" ]
},
{
"long_name" : "New York",
"short_name" : "New York",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "New York",
"short_name" : "NY",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United States",
"short_name" : "US",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "SoHo, New York, NY, USA",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 40.7283442,
"lng" : -73.9953929
},
"southwest" : {
"lat" : 40.7184446,
"lng" : -74.0054619
}
},
"location" : {
"lat" : 40.723384,
"lng" : -74.001704
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 40.7283442,
"lng" : -73.9953929
},
"southwest" : {
"lat" : 40.7184446,
"lng" : -74.0054619
}
}
},
"types" : [ "neighborhood", "political" ]
}
],
"status" : "OK"
}
有比使用 Google 的地理编码 API 的边界框更好的方法吗?
【问题讨论】:
-
您找到解决方案了吗?我正在寻找此信息的来源。如果 google api 有它,那将非常有帮助。
标签: google-maps google-maps-api-3 geocoding geojson polygons