Когда я пытаюсь выполнить поиск в Place Autocomplete, я получаю Не удается загрузить результаты поиска и журналы говорят
"Error while autocompleting: OVER_QUERY_LIMIT"
Я включил https://console.cloud.google.com/ и ключ API работает хорошо.
Java-код
String apiKey = "MY API KEY";
private RadioGroup mRadioGroup;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_costumer_map);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
Places.initialize(getApplicationContext(), apiKey);
PlacesClient placesClient = Places.createClient(this);
// Initialize the AutocompleteSupportFragment.
AutocompleteSupportFragment autocompleteFragment = (AutocompleteSupportFragment)
getSupportFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
// Specify the types of place data to return.
autocompleteFragment.setPlaceFields(Arrays.asList(Place.Field.ID, Place.Field.NAME));
// Set up a PlaceSelectionListener to handle the response.
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(Place place) {
destination = place.getName().toString();
destinationLatLng = place.getLatLng();
Log.i(TAG, "Place: " + place.getName() + ", " + place.getId());
}
@Override
public void onError(Status status) {
Log.e(TAG, "onError: " + status);
}
});
XML-код
<android.support.v7.widget.CardView
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_below = "@+id/toolbar"
android:layout_margin = "20sp">
<fragment
android:id = "@+id/place_autocomplete_fragment"
android:name = "com.google.android.libraries.places.widget.AutocompleteSupportFragment"
android:layout_width = "match_parent"
android:layout_height = "wrap_content" />
</android.support.v7.widget.CardView>
OVER_QUERY_LIMIT указывает, что вы превысили свою квоту.
Основная причина:
If you exceed the usage limits you will get an OVER_QUERY_LIMIT status code as a response.
This means that the web service will stop providing normal responses and switch to returning only status code OVER_QUERY_LIMIT until more usage is allowed again. This can happen:
- Within a few seconds, if the error was received because your application sent too many requests per second.
- Within the next 24 hours, if the error was received because your application sent too many requests per day. The daily quotas are reset at midnight, Pacific Time.
Вы также можете проверить это для получения более подробной информации: https://developers.google.com/maps/premium/previous-licenses/articles/usage-limits
Для увеличения лимита использования вам необходимо иметь платный аккаунт. вы должны заплатить за обновление лимита.
Это плохо :( , спасибо за помощь ^_^
Для получения дополнительной информации вы также можете проверить это: Developers.google.com/maps/documentation/directions/…
Вы получаете сообщение OVER_QUERY_LIMIT потому что вы не включили биллинг для своего проекта в консоль разработчиков.
To use the Places SDK for Android, you must include an API key with all API requests and you must enable billing on each of your projects.
Проверьте эта ссылка для получения дополнительной информации и цен.
Артикул: Основные данные
Fields in the Basic category are included in the base cost of the Places request, and do not result in any additional charge. The Basic Data SKU is triggered when any of these fields are requested: ADDRESS, ID, LAT_LNG, NAME, OPENING_HOURS, PHOTO_METADATAS, PLUS_CODE, TYPES, USER_RATINGS_TOTAL, VIEWPORT.
Вы можете проверить цены и другие артикулы в та же ссылка, указанном выше.
Чувак, это сложно, что-то насчет выставления счетов ?
Вы получите сообщение об ошибке PLACES_API_RATE_LIMIT_EXCEEDED, если используете устаревшую версию Places SDK для Play Services com.google.android.gms:play-services-places, как объяснено здесь:
Notice: If your Android app is experiencing 9005 PLACES_API_RATE_LIMIT_EXCEEDED errors, you may be using a deprecated version of the Places SDK for Android. The Google Play Services version of the Places SDK for Android (for example com.google.android.gms:play-services- places) was deprecated as of January 29, 2019, and was turned off on July 29, 2019. A new version of the Places SDK for Android is now available. We recommend updating to the new version as soon as possible. For details, see the migration guide.
Вы должны заменить следующую строку в вашем build.gradle:
implementation 'com.google.android.gms:play-services-places:<VERSION>'
С участием:
implementation 'com.google.android.libraries.places:places:2.2.0'
Обратите внимание, что для версии 2 или выше требуется androidx. На момент написания последней версией, не требующей androidx, была 1.1.0.
Спасибо за попытку помочь, но я не могу использовать его с первого дня, как я могу использовать свой лимит