Android根据已知的经纬度坐标获取当前位置-古蔺大橙子建站
RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
Android根据已知的经纬度坐标获取当前位置

例如:经度:10.123456   纬度:20.654321

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:空间域名、网站空间、营销软件、网站建设、奎文网站维护、网站推广。

          

根据以上坐标获取到实际位置(不借用百度地图或高德地图的API)

代码如下:

//放入经纬度就可以了
public String getAddress(double latitude, double longitude) {
        Geocoder geocoder = new Geocoder(this, Locale.getDefault());

        try {
            List
 addresses = geocoder.getFromLocation(latitude,                     longitude, 1);             if (addresses.size() > 0) {                 Address address = addresses.get(0);                 String data = address.toString();                 int startCity = data.indexOf("1:\"") + "1:\"".length();                 int endCity = data.indexOf("\"", startCity);                 String city = data.substring(startCity, endCity);                 int startPlace = data.indexOf("feature=") + "feature=".length();                 int endplace = data.indexOf(",", startPlace);                 String place = data.substring(startPlace, endplace);                 return city + place ;             }         } catch (IOException e) {             e.printStackTrace();         }         return "获取失败";     }

网页名称:Android根据已知的经纬度坐标获取当前位置
网站地址:http://scgulin.cn/article/iejjso.html