When I try to search at Place Autocomplete I got Can't Load Search Results and the logs say
"Error while autocompleting: OVER_QUERY_LIMIT"
I have enabled https://console.cloud.google.com/ and API key works well.
Java Code
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 Code
<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>
If you're building a client-side application, take a look at the Places SDK for Android, the Places SDK for iOS, and the Places Library, Maps JavaScript API. The Place Autocomplete service is a web service that returns place predictions in response to an HTTP request.
The autocomplete request is available at no charge, and the subsequent Place Details call gets charged based on regular Place Details pricing. A Place Details request generates Data SKUs (Basic, Contact, and/or Atmosphere) – depending on the fields that are specified in the request.
The Place Autocomplete service can match on full words and substrings, resolving place names, addresses, and plus codes. Applications can therefore send queries as the user types, to provide on-the-fly place predictions.
If you're building a client-side application, take a look at the Places SDK for Android, the Places SDK for iOS, and the Places Library, Maps JavaScript API . The Place Autocomplete service is a web service that returns place predictions in response to an HTTP request. The request specifies a textual search string and optional geographic bounds.
A random string which identifies an autocomplete session for billing purposes. The session begins when the user starts typing a query, and concludes when they select a place and a call to Place Details is made. Each session can have multiple queries, followed by one place selection.
Note: You can use Place Autocomplete even without a map. If you do show a map, it must be a Google map. When you display predictions from the Place Autocomplete service without a map, you must include the ' Powered by Google ' logo displayed inline with the search field/results.
You are getting OVER_QUERY_LIMIT message because you have not enabled billing for your project in developers console.
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.
Check this link for more info and pricing.
SKU: Basic Data
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.
You can check pricing and other SKUs in the same link given above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With