I'm creating an app based on places search. I would like to know how can I add a search bar into my Google Map, where the user can select a Place, and I can capture what the user chose.
I'm trying to include an autocomplete Search Box that is displayed above the Google Map in the UI.
You can simply use a PlaceAutoCompleteFragment.
First ensure that you're using the latest version of Google Play Services (Version 8.4.0 and up includes the PlaceAutoCompleteFragment class):
Then include the PlaceAutoCompleteFragment in your xml layout:
Then set up a listener in your Activity:
When you run this code, you'll see the AutoComplete bar above the Google Map:
When you click on the AutoComplete bar, it will look like this:
Then, start typing, and select a Place:
When you tap on a place to select it, you will see the log from the PlaceSelectionListener:
Yes, you can do that by make method for addMarker when you press on the place, You can use this code:
}