用于传递lon / lat并返回城市名称的API

时间:2011-07-17 00:57:33

标签: android api latitude-longitude city

我想在我的Android应用程序中使用一个API(如果支持谷歌地图,则优先使用谷歌地图)来传递位置的经度/纬度,API返回城市名称。

在解决方案中,你应该去getAddressLine(x)

3 个答案:

答案 0 :(得分:2)

我相信谷歌确实提供了您在这里要求的内容 http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding

答案 1 :(得分:2)

我认为API的速率有限。即你不能在一小时内多次点击API .Android包含一个Geocoder类,它也可以进行ReverseGeocoding。看看this link

答案 2 :(得分:1)

Geonames.org是另一个。以下是在西雅图附近查找名称的示例API调用: http://api.geonames.org/citiesJSON?north=47.65&south=47.55&east=-122.30&west=-122.40&lang=de&username=demo

{
    "geonames": [
        {
            "fcodeName": "seat of a second-order administrative division",
            "countrycode": "US",
            "fcl": "P",
            "fclName": "city, village,...",
            "name": "Seattle",
            "wikipedia": "",
            "lng": -122.3320708,
            "fcode": "PPLA2",
            "geonameId": 5809844,
            "lat": 47.6062095,
            "population": 608660
        },
        {
            "fcodeName": "populated place",
            "countrycode": "US",
            "fcl": "P",
            "fclName": "city, village,...",
            "name": "Yesler Terrace",
            "wikipedia": "",
            "lng": -122.3159591,
            "fcode": "PPL",
            "geonameId": 5816674,
            "lat": 47.6009318,
            "population": 0
        },
        {
            "fcodeName": "section of populated place",
            "countrycode": "US",
            "fcl": "P",
            "fclName": "city, village,...",
            "name": "North Broadway",
            "wikipedia": "",
            "lng": -122.3204044,
            "fcode": "PPLX",
            "geonameId": 5804929,
            "lat": 47.6462094,
            "population": 0
        },
        {
            "fcodeName": "populated place",
            "countrycode": "US",
            "fcl": "P",
            "fclName": "city, village,...",
            "name": "Capitol Hill",
            "wikipedia": "",
            "lng": -122.3195706,
            "fcode": "PPL",
            "geonameId": 5789123,
            "lat": 47.6234317,
            "population": 0
        },
        {
            "fcodeName": "populated place",
            "countrycode": "US",
            "fcl": "P",
            "fclName": "city, village,...",
            "name": "Interbay",
            "wikipedia": "",
            "lng": -122.3959623,
            "fcode": "PPL",
            "geonameId": 5798384,
            "lat": 47.641209,
            "population": 0
        },
        {
            "fcodeName": "populated place",
            "countrycode": "US",
            "fcl": "P",
            "fclName": "city, village,...",
            "name": "Ross (historical)",
            "wikipedia": "",
            "lng": -122.3623502,
            "fcode": "PPL",
            "geonameId": 5808844,
            "lat": 47.6478758,
            "population": 0
        },
        {
            "fcodeName": "populated place",
            "countrycode": "US",
            "fcl": "P",
            "fclName": "city, village,...",
            "name": "Stevens",
            "wikipedia": "",
            "lng": -122.3066667,
            "fcode": "PPL",
            "geonameId": 7153940,
            "lat": 47.6297222,
            "population": 0
        },
        {
            "fcodeName": "section of populated place",
            "countrycode": "US",
            "fcl": "P",
            "fclName": "city, village,...",
            "name": "Belltown",
            "wikipedia": "",
            "lng": -122.3509605,
            "fcode": "PPLX",
            "geonameId": 5786913,
            "lat": 47.6164871,
            "population": 0
        },
        {
            "fcodeName": "populated place",
            "countrycode": "US",
            "fcl": "P",
            "fclName": "city, village,...",
            "name": "Queen Anne",
            "wikipedia": "",
            "lng": -122.366239,
            "fcode": "PPL",
            "geonameId": 5807648,
            "lat": 47.6359314,
            "population": 0
        },
        {
            "fcodeName": "populated place",
            "countrycode": "US",
            "fcl": "P",
            "fclName": "city, village,...",
            "name": "South Seattle",
            "wikipedia": "",
            "lng": -122.312903,
            "fcode": "PPL",
            "geonameId": 5811509,
            "lat": 47.5614876,
            "population": 0
        }
    ]
}