[英]Geocode get Latitude and Longitude from address
我试图从ArrayList中的地址获取经度和纬度,并在另一个Arraylist中写入纬度和经度。 没用 在ArrayList中,User是用户的地址,在ArrayList中,latlon是纬度和经度。
Geocoder coder = new Geocoder(this);
Iterator<User>ite=Profile.User.listIterator();
List<Address>address;
User temp=null;
int br=0;
while(ite.hasNext()){
temp=ite.next();
address=coder.getFromLocationName(temp.Useraddress,1);
Address location = address.get(br);
UserLocation.latlon.add(new latlon(location.getLatitude(), location.getLongitude()));
br++;
}
在这里,我为您提供了从地址获取经/纬度的示例代码。 尝试这个 :
Geocoder coder = new Geocoder(this);
List<Address> address;
try {
address = coder.getFromLocationName(strAddress,5);
if (address == null) {
return null;
}
Address location = address.get(0);
lat = location.getLatitude();
lng = location.getLongitude();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.