我有一个包含经纬度的标记的MongoDB数据库,我需要另一个数据库(或其他解决方案)来包含城市或区域级别边界。如果使用Geojson多边形会更好。
我有一个名为city的字段(例如 'city' : 'New York'
),但我想缩小到城市区域/社区层面,例如“Soho”。解决这个问题的想法基于谷歌新地图。如果我们输入区域或邮政编码,我们会看到该区域的红色点状多边形。
我看过Maxmind的数据库,但它没有每个城市的边界。
到目前为止,我最好的解决方案是使用Google 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边界框更好的方法?