如何获得地址,如果我们在Android中使用定位API给纬度和经度 [英] How to get addresses if we give latitude and longitude using location API in Android

查看:171
本文介绍了如何获得地址,如果我们在Android中使用定位API给纬度和经度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,我试图让根据纬度,经度coordinates.When我尝试打印特定坐标的所有地址的位置地址的应用程序,我只得到一个地址。有没有什么办法来获取提供的坐标所有地址的列表。我的code段是如下:

I have an application where I try to get address of a location based on the latitude,longitude coordinates.When I try to print all the address of particular coordinates , I am getting only single address. IS there any way to get the list of all addresses for the coordinates supplied . My code snippet is as below:

在哪里locationLatitude,locationLongitude是String类型会转换为双打

Where locationLatitude,locationLongitude are of type String which are converted to doubles

* 列表中的地址=地理coder.getFromLocation(双人间
                .parseDouble(locationLatitude),Double.parseDouble(locationLongitude),1);
        StringBuffer的addressAsString =新的StringBuffer();
            如果(!addresses.isEmpty()){
        的for(int i = 0; I< addresses.get(0).getMaxAddressLineIndex();我++)
        addressAsString.append(addresses.get(0).getAddressLine(ⅰ)+\\ n);
                      返回addressAsString.toString();
的*

*List addresses = geoCoder.getFromLocation(Double .parseDouble(locationLatitude), Double.parseDouble(locationLongitude), 1); StringBuffer addressAsString = new StringBuffer(""); if(!addresses.isEmpty()){ for (int i = 0; i < addresses.get(0).getMaxAddressLineIndex(); i++) addressAsString.append(addresses.get(0).getAddressLine(i) + "\n"); return addressAsString.toString() ;*

我将等待任何答复。
先谢谢了。

I will be waiting for any reply. Thanks in Advance.

推荐答案

您必须仔细阅读API:

You must read the api carefully:

的公共方法
清单getFromLocation(双纬度,经度双,诠释的maxResults)

Public Methods List getFromLocation(double latitude, double longitude, int maxResults)

返回已知描述的区域立即给定的纬度和经度周围地址的阵列

Returns an array of Addresses that are known to describe the area immediately surrounding the given latitude and longitude.

如果你改变的maxResults参数从1至10,然后10个结果将若有退回。

If you change maxResults parameter from 1 to 10, then 10 results will returned if there has.

List addresses = geoCoder.getFromLocation(Double .parseDouble(locationLatitude), Double.parseDouble(locationLongitude), 10); 

这篇关于如何获得地址,如果我们在Android中使用定位API给纬度和经度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆