简体   繁体   English

转换地址为lat long时,地理编码google api卡住了

[英]geocode google api stuck when convert address to lat long

When I hit Geocode Google API with Ukrain address it will return null for some addresses at client (in Ukrain) but when I test it in India (at my side) it works perfect. 当我点击带有乌克兰地址的Geocode Google API时,它会在客户端(乌克兰)的某些地址返回null ,但是当我在印度(在我身边)测试它时,它的工作非常完美。

Code: 码:

private LatLng getLocationFromAddress(final String place){
    LatLng loc = null;
    Geocoder gCoder = new Geocoder(getActivity() );

    try {
        final List<Address> list = gCoder.getFromLocationName(place, 1);

        if (list != null && list.size() > 0) {
            loc = new LatLng(list.get(0).getLatitude(), list.get(0).getLongitude());
        }
    }
    catch (IOException e) {
        e.printStackTrace();
    }

    return loc;
}

Show the code. 显示代码。 Also check if the address is not null from api 同时检查api中的地址是否为空

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM