Android:获取所有城市,城镇,邮政编码

时间:2013-07-24 15:29:15

标签: android google-maps-api-3 geolocation location google-places-api

我需要找到距离纬度和经度指定地方20公里半径范围内的所有城市,城镇或邮政编码。

我已使用此查询从Google Places API尝试Places search

https://maps.googleapis.com/maps/api/place/radarsearch/json?location=53.09022140,21.21483510&radius=20000&types=(locality|postal_code)&sensor=false&key=myKey

但这似乎不适用于地理编码场所(仅显示业务结果)。

我还阅读了Google地图JavaScript API v3的Places Library中的地方搜索,但我不确定这是否适合Android应用程序(我有一个http / php服务器,但我是不知道如何在我的Android应用程序中使用它。我可以直接从我的应用程序中使用它吗?

也许我可以使用其他服务来实现它?你有什么建议吗?

1 个答案:

答案 0 :(得分:0)

我意识到这个问题很老,但是由于没有人回答,我想我会分享如何解决这个问题。

有两种方法可以解决此问题。首先是通过使用此处提供的信息来创建自己的地点数据库:http://download.geonames.org/export/dump/

这不太难,但是如果没有时间,可能会很痛苦。

也有很多第三方服务可以为您做到这一点。我运行了一项名为https://geo-info.co/

的服务

在这种情况下,我们几乎可以满足您的需求。

https://geo-info.co/53.09022140,21.21483510

会将最近的城市以及其他10个最近的邻近城市返回到这些坐标。

{
    "city": "Perzanki-Borek",
    "community": "Gmina Krasnosielc",
    "community2": "141104",
    "country": "PL",
    "county": "Powiat makowski",
    "county2": "1411",
    "latitude": "53.0902",
    "longitude": "21.2113",
    "nearby": [
        {
            "city": "Grabowo",
            "community": "Gmina Krasnosielc",
            "community2": "141104",
            "country": "PL",
            "county": "Powiat makowski",
            "county2": "1411",
            "latitude": "53.0809",
            "longitude": "21.2201",
            "state": "Mazovia",
            "state2": "78",
            "zipcode": "06-212"
        },
        {
            "city": "Papierny Borek",
            "community": "Gmina Krasnosielc",
            "community2": "141104",
            "country": "PL",
            "county": "Powiat makowski",
            "county2": "1411",
            "latitude": "53.0885",
            "longitude": "21.1844",
            "state": "Mazovia",
            "state2": "78",
            "zipcode": "06-214"
        },
        {
            "city": "W\u00f3lka Rakowska",
            "community": "Gmina Krasnosielc",
            "community2": "141104",
            "country": "PL",
            "county": "Powiat makowski",
            "county2": "1411",
            "latitude": "53.1019",
            "longitude": "21.1767",
            "state": "Mazovia",
            "state2": "78",
            "zipcode": "06-214"
        },
        {
            "city": "Amelin",
            "community": "Gmina Krasnosielc",
            "community2": "141104",
            "country": "PL",
            "county": "Powiat makowski",
            "county2": "1411",
            "latitude": "53.0646",
            "longitude": "21.2376",
            "state": "Mazovia",
            "state2": "78",
            "zipcode": "06-212"
        },
        {
            "city": "Raki",
            "community": "Gmina Krasnosielc",
            "community2": "141104",
            "country": "PL",
            "county": "Powiat makowski",
            "county2": "1411",
            "latitude": "53.0766",
            "longitude": "21.1691",
            "state": "Mazovia",
            "state2": "78",
            "zipcode": "06-214"
        },
        {
            "city": "Bagienice-Folwark",
            "community": "Gmina Krasnosielc",
            "community2": "141104",
            "country": "PL",
            "county": "Powiat makowski",
            "county2": "1411",
            "latitude": "53.0644",
            "longitude": "21.1855",
            "state": "Mazovia",
            "state2": "78",
            "zipcode": "06-212"
        },
        {
            "city": "El\u017cbiecin",
            "community": "Gmina Krasnosielc",
            "community2": "141104",
            "country": "PL",
            "county": "Powiat makowski",
            "county2": "1411",
            "latitude": "53.0909",
            "longitude": "21.161",
            "state": "Mazovia",
            "state2": "78",
            "zipcode": "06-214"
        },
        {
            "city": "Adamczycha",
            "community": "Gmina Baranowo",
            "community2": "141501",
            "country": "PL",
            "county": "Powiat ostro\u0142\u0119cki",
            "county2": "1415",
            "latitude": "53.1072",
            "longitude": "21.2633",
            "state": "Mazovia",
            "state2": "78",
            "zipcode": "06-320"
        },
        {
            "city": "Bagienice Szlacheckie",
            "community": "Gmina Krasnosielc",
            "community2": "141104",
            "country": "PL",
            "county": "Powiat makowski",
            "county2": "1411",
            "latitude": "53.0553",
            "longitude": "21.2046",
            "state": "Mazovia",
            "state2": "78",
            "zipcode": "06-212"
        },
        {
            "city": "Ruzieck",
            "community": "Gmina Krasnosielc",
            "community2": "141104",
            "country": "PL",
            "county": "Powiat makowski",
            "county2": "1411",
            "latitude": "53.0812",
            "longitude": "21.2733",
            "state": "Mazovia",
            "state2": "78",
            "zipcode": "06-212"
        }
    ],
    "state": "Mazovia",
    "state2": "78",
    "zipcode": "06-212"
}