[英]Some addresses are not shown on android map
为什么getLocationFromAddress对某些地址返回0结果
例如:1460 NW Gilman Blvd(Starbucks)Issaquah,WA 98027。 。
如果我在maps.google中介绍这一点,那么我会收到要点,但电话号码为。
我提到,对于其他地址,它通常在95%的情况下有效。 当它不起作用时,这是个例外。 即使我删除()中的内容,我也有0个结果。
LatLng addressPoint = MapUtils.getLocationFromAddress(address, this);
public static LatLng getLocationFromAddress(String strAddress, Context ctx) {
Geocoder coder = new Geocoder(ctx);
List<Address> address;
LatLng p1 = null;
try {
address = coder.getFromLocationName(strAddress, 5);
if (address == null || address.size()<1) {
return null;
}
Address location = address.get(0);
location.getLatitude();
location.getLongitude();
p1 = new LatLng(location.getLatitude(), location.getLongitude() );
} catch (Exception ex) {
ex.printStackTrace();
}
return p1;
}
Android文档的“ 位置地址”部分对此进行了介绍。
我无法确认您是否已经完成此操作,但是您需要一个Intent服务来获取地址。 完成后,在清单上对其进行定义,然后在其中创建Geocoder
,该Geocoder
调用您将使用的必要方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.