2011-01-21 155 views

回答

6

退房的方法Geocoder.getFromLocationName(cityName, maxResults)

使用方法如下:

List<Address> addressList = geoCoder.getFromLocationName(cityName, 1); 
Address address = addressList.get(0); 
if(address.hasLatitude() && address.hasLongitude()){ 
    double selectedLat = address.getLatitude(); 
    double selectedLng = address.getLongitude(); 
} 
+0

谢谢Sheikh..let我只是检查它 – user264953 2011-01-21 05:27:03

+0

完美!非常感谢.. – user264953 2011-01-21 05:43:45

5

喜试试下面的代码从指定的地址地理编码点。

List<Address> foundGeocode = null; 
/* find the addresses by using getFromLocationName() method with the given address*/ 
foundGeocode = new Geocoder(this).getFromLocationName("address here", 1); 
foundGeocode.get(0).getLatitude(); //getting latitude 
foundGeocode.get(0).getLongitude();//getting longitude 
1

嗨,

有一个很不错的网站叫做拥有数据,你 需要,在一个整洁,下载的文件( 城市名)

http://www.world-gazetteer.com/home.htm的 世界地名录

从主页面点击链接 即:

其他统计.....各种 统计:表格,地图和 下载数据

,并从出现的页面中,单击 写着链接:

popdata(1.4 MB)

解压缩文件,你就知道了!

该数据库是免费的世界各大城市的主数据库 ,其中包括 纬度,经度和人口 数据等。

得到这个来自:http://answers.google.com/answers/threadview?id=432778

0

试试这个。

Geocoder geoCoder = new Geocoder(getBaseContext(), Locale.getDefault()); 
try { 
    List<Address> addresses = geoCoder.getFromLocation(latitude , longitude, 1); 

    String strCompleteAddress= ""; 
    //if (addresses.size() > 0) 
    //{ 
     for (int i=0; i<addresses.get(0).getMaxAddressLineIndex();i++) 
      strCompleteAddress+= addresses.get(0).getAddressLine(i) + "\n"; 
    // } 
    Log.i("MyLocTAG => ", strCompleteAddress); 
    Toast.makeText(getBaseContext(), strCompleteAddress, Toast.LENGTH_LONG).show(); 
} 
catch (IOException e) { 
    Log.i("MyLocTAG => ", "this is the exception part"); 
    e.printStackTrace(); 
} 
相关问题