我如何才能找到从地址的经纬度? [英] How can I find the latitude and longitude from address?
本文介绍了我如何才能找到从地址的经纬度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要显示在谷歌地图的地址的位置。
我如何使用谷歌地图API的地址的纬度和经度?
解决方案
公开的GeoPoint getLocationFromAddress(字符串strAddress){
地理codeR codeR =新的地缘codeR(本);
名单<地址>地址;
的GeoPoint P1 = NULL;
尝试 {
地址= coder.getFromLocationName(strAddress,5);
如果(地址== NULL){
返回null;
}
地址位置= address.get(0);
location.getLatitude();
location.getLongitude();
P1 =新的GeoPoint((INT)(location.getLatitude()* 1E6)
(中间体)(location.getLongitude()* 1E6));
返回P1;
}
}
strAddress
是包含地址的字符串。该地址
变量保存转换后的地址。
I want to show the location of an address in Google Maps.
How do I get the latitude and longitude of an address using the Google Maps API?
解决方案
public GeoPoint getLocationFromAddress(String strAddress){
Geocoder coder = new Geocoder(this);
List<Address> address;
GeoPoint p1 = null;
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
is a string containing the address. The address
variable holds the converted addresses.
这篇关于我如何才能找到从地址的经纬度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文