地理编码器功能不起作用。

3

我一直在使用Google API根据经纬度获取位置地址。这一直运行良好,但今天突然出现了以下错误消息:

我已经完成了

geocoder = new Geocoder(MapNavigation.this, Locale.ENGLISH);
                addresses = geocoder.getFromLocation(lat, lon, 1);

HTTP request blocked due to automatic backoff: https://www.google.com/loc/m/api
Blocked by temporary_blocked2: https://www.google.com/loc/m/api
com.google.android.gms.http.a: Blocked by rule: temporary_blocked2

请回复任何一个!!!! - DUKE
这似乎是偶尔发生的情况:https://www.reddit.com/r/androiddev/comments/2q6pgq/timeout_problems_with_the_builtin_geocoder/ - 请在几个小时后再试。此外,请确保您没有超过API的配额限制。 - TomTasche
谢谢Tom,但请告诉我什么是API配额。 - DUKE
每秒10个请求,每天2500个:https://developers.google.com/maps/documentation/geocoding/usage-limits - TomTasche
3个回答

2

0
使用以下代码,我能够在不使用Google-API的情况下获取位置信息,但是在OnePlus设备上无法正常工作。 已经测试过网络连接。 如果有人对此问题有任何想法,请回复。
if (Geocoder.isPresent())
                    {
                        try
                        {
                            Geocoder geocoder = new Geocoder(contex, Locale.getDefault());
                            List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
                            if (addresses.size() > 0)
                            {
                                fullAddress = addresses.get(0).getAddressLine(0);
                                addresses.get(0).getSubLocality();
                                street=addresses.get(0).getPremises()+","+addresses.get(0).getFeatureName()+","+addresses.get(0).getSubLocality()+","+addresses.get(0).getLocality();
                                locality = addresses.get(0).getSubLocality();
                                city = addresses.get(0).getSubAdminArea();
                                state = addresses.get(0).getAdminArea();
                                country = addresses.get(0).getCountryName();
                            }
                        }
                        catch (Exception ignored)
                        {
                            // after a while, Geocoder start to trhow "Service not availalbe" exception. really weird since it was working before (same device, same Android version etc..
                        }
                    }

0
我们也遇到了同样的问题。Google服务的onLocationChanged也无法工作 :-(。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接