如何获得经/纬度基于android系统中输入的地址? [英] How to get latitude/longitude based on entered address in android?
本文介绍了如何获得经/纬度基于android系统中输入的地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想得出输入源与放大器的基础上的路线;目的地址。我需要得到纬度/地址的基础上绘制的Android地图。所以,我怎么能得到纬度/输入地址的基础上。
地理codeR地理codeR =新的地缘codeR(getBaseContext(),Locale.getDefault());
尝试 {
名单<地址>地址=地理coder.getFromLocationName(禄,1);
字符串添加=「;
如果(addresses.size()大于0)
{
加= addresses.get(0);
}
Toast.makeText(getBaseContext(),添加,Toast.LENGTH_SHORT).show();
}赶上(IOException异常E){
Toast.makeText(getBaseContext(),e.getMessage(),Toast.LENGTH_LONG).show();
}
解决方案
使用的谷歌地理编码API来获取坐标地址:http://$c$c.google.com/apis/maps/documentation/javascript/services.html#Geocoding
I wanna draw a route on the basis of the entered source & destination address. I need to get lat/log on the basis of address to draw a map in android. So how can i get lat/log on the basis of entered address.
Geocoder geoCoder = new Geocoder( getBaseContext(), Locale.getDefault());
try {
List<Address> addresses = geoCoder.getFromLocationName("Loc",1);
String add = "";
if (addresses.size() > 0)
{
add = addresses.get(0);
}
Toast.makeText(getBaseContext(), add, Toast.LENGTH_SHORT).show();
} catch (IOException e) {
Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_LONG).show();
}
解决方案
Use the Google Geocoding API to get coordinates for an address: http://code.google.com/apis/maps/documentation/javascript/services.html#Geocoding
这篇关于如何获得经/纬度基于android系统中输入的地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文