我正在开发Android应用,其中我在编辑文本中占据目的地,我想要输入位置的纬度和经度。
示例:我现在输入了编辑文本pune我想要它的纬度和经度。
答案 0 :(得分:0)
从这里开始:https://stackoverflow.com/a/3574792/2065418
Geocoder coder = new Geocoder(this);
List<Address> address;
try {
address = coder.getFromLocationName(strAddress,5);
if (address == null) {
return null;
}
Address location = address.get(0);
location.getLatitude();
location.getLongitude();
p1 = new GeoPoint((int) (location.getLatitude() * 1E6),
(int) (location.getLongitude() * 1E6));
return p1;
}
strAddress
是包含地址的字符串。 address
变量保存已转换的地址。