开发者

API to pass lon/lat and return city name

开发者 https://www.devze.com 2023-03-20 16:26 出处:网络
I would like to use an API (preferred to be google maps if it\'s supported) in my android application to pass the longitude/latitude of a location and the API r开发者_运维知识库eturns the city name.

I would like to use an API (preferred to be google maps if it's supported) in my android application to pass the longitude/latitude of a location and the API r开发者_运维知识库eturns the city name.

In the solution to this, you should go for getAddressLine(x)


I believe that the APIs are rate limited. i.e you cannot hit the API for more than a number of times in a hour.. Android contains a Geocoder class which does ReverseGeocoding as well.. Take a look at this link.


i believe google does provide what you are requesting here http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding


Geonames.org is another. Here's a sample API call to find names near Seattle: 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
        }
    ]
}
0

精彩评论

暂无评论...
验证码 换一张
取 消