【发布时间】:2011-09-09 04:01:17
【问题描述】:
如何查找特定位置的经度和纬度?
用户在edittext中输入位置并单击搜索按钮,然后该位置将显示在googlemap中。
我为此使用了以下代码,但这会给出错误“服务不可用”
地理编码器 geoCoder = new Geocoder(this, Locale.getDefault()); 尝试 { 地址=geoCoder.getFromLocationName(txtlocation.getText().toString(), 1).get(0); 双 longi=address.getLongitude(); 双纬度=地址.getLatitude(); System.out.println("经度:--- " +longi); System.out.println("纬度:---" +latit); } 捕捉(IOException e){ // TODO 自动生成的 catch 块 e.printStackTrace(); Toast.makeText(MapRouteActivity.this, e.toString(), Toast.LENGTH_LONG).show(); }【问题讨论】:
-
你为什么不使用 locationManager。
-
在我的应用程序中,我使用了 locationmanager,但这里没有显示。
-
先仰望夜空,找到北极星.... ;)
标签: android