android地图上没有显示某些地址

时间:2016-01-15 14:36:35

标签: android google-maps google-api

为什么getLocationFromAddress为某些地址返回0 rezults

Ex:1460 NW,Gilman Blvd(星巴克),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;
}

1 个答案:

答案 0 :(得分:0)

Android文档的Location Address部分介绍了这一点。

我无法确认您是否已经完成此操作,但您需要一个Intent服务来获取地址。完成后,在Manifest上定义它,然后创建Geocoder,调用您将使用的必要方法。

相关问题