0

I am a newbie to android and google maps. Basically, I want to provide a search bar besided my mapview to users. The search bar should enable user to search for restaurants. I tried using the google autocomplete API . However, when I type one character to it, it returns null .

The code for my layout xml is :

<fragment
        android:id="@+id/place_autocomplete_fragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"    android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"/>

And I am simply loading this xml from my fragment class. Do I need to do anything in my fragment class to make this work?

Thanks a lot.

learntogrow-growtolearn
  • 1,190
  • 5
  • 13
  • 37
  • 1
    Yeah, you need some java logic, even the layout piece of code seems incomplete, I'd put there an AutoCompleteTextView. – slanecek Jul 18 '16 at 21:23
  • Hi @slanecek , Can you please provide some tutorial link ? That will be very much helpful – learntogrow-growtolearn Jul 18 '16 at 21:47
  • You can get some inspiration from this post https://stackoverflow.com/questions/35602027/get-other-values-according-to-the-item-selected-in-autocompletetextview – slanecek Jul 18 '16 at 21:51

2 Answers2

0

There are many tutorials on the internet that can help you with your problem. From the Google documentation itself, they have a guideline on what autocomplete can do plus some sample code. The autocomplete service in the Google Places API for Android returns place predictions in response to user search queries. As the user types, the autocomplete service returns suggestions for places such as businesses, addresses and points of interest.

You can add autocomplete to your app in the following ways:

Just check the documentation above for more information.

For the different tutorials, you can follow either of these:

KENdi
  • 7,576
  • 2
  • 16
  • 31
0

error_message_screen_shot

I went to postman and paste the query to see what result do I get. Apparently, I didn't enable Billing in Google Cloud Platform.

Possible Solution:

  1. Try enabling Billing in your Google Cloud Platform by filling up your debit/credit card info to start free trial.
  2. Check if you enabled "Places API" in your Google Cloud Platform
Yu Hao
  • 119,891
  • 44
  • 235
  • 294
Lolz
  • 51
  • 1
  • 2