在android中存儲經度和緯度數據

[英]Storing longitude and latitude data in android


I have to store longitude and latitude of all cities of a country in android application

我必須在android應用程序中存儲一個國家的所有城市的經度和緯度

when user will select a city i have to return the longitude and latitude of selected city.

當用戶選擇一個城市時,我必須返回所選城市的經度和緯度。

what will be the most efficient way to do this?

什么是最有效的方法呢?

or is there any resources where i enter a country and it will show all cities with their longitude and latitude..?

或者我進入一個國家是否有任何資源,它將顯示所有城市的經度和緯度..?

1 个解决方案

#1


0  

You can use Google Geocoding API : https://developers.google.com/maps/documentation/geocoding/

您可以使用Google地理編碼API:https://developers.google.com/maps/documentation/geocoding/

For example : https://maps.googleapis.com/maps/api/geocode/json?address=Berlin&sensor=true And parse output using GSON

例如:https://maps.googleapis.com/maps/api/geocode/json?address = Berlin&_sensor = true並使用GSON解析輸出

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "Berlin",
               "short_name" : "Berlin",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Berlin",
               "short_name" : "Berlin",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Niemcy",
               "short_name" : "DE",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Berlin, Niemcy",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 52.6754542,
                  "lng" : 13.7611176
               },
               "southwest" : {
                  "lat" : 52.33962959999999,
                  "lng" : 13.0911663
               }
            },
            "location" : {
               "lat" : 52.52000659999999,
               "lng" : 13.404954
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 52.6754542,
                  "lng" : 13.7611176
               },
               "southwest" : {
                  "lat" : 52.33962959999999,
                  "lng" : 13.0911663
               }
            }
         },
         "types" : [ "locality", "political" ]
      }
   ],
   "status" : "OK"
}

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2014/03/11/7f8c02e1391484d582b01c653b55a879.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com