简体   繁体   中英

Showing nearby places in google map search android

I don't want have different countries search suggestions in my app(Image)

I want to have correct or nearest suggestions in google map app(Image)

I have tested with this code

autocompleteFragment = (PlaceAutocompleteFragment)
                getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
                .setTypeFilter(AutocompleteFilter.TYPE_FILTER_REGIONS)
                .build();  

autocompleteFragment.setFilter(typeFilter);

I want to show nearby places when I am typing in search bar. My problem is when one character was entered in search bar, that character related other country places coming as suggestions, I want it to be very nearest one. In other words the search is much similar like android google maps app.

AutocompleteFilter filter = new AutocompleteFilter.Builder()
            .setTypeFilter(AutocompleteFilter.TYPE_FILTER_CITIES)
            .build();

AutoCompleteSearch component which doesn't show nearby places. I had achieved by using Google Map web-service API.

Web-API: maps.googleapis.com/maps/api/place/nearbysearch (GET)
parameters: key(Your API key),
location(lat+","+lang),
radius(5000),
sensor(true)
NOTE: I enabled Google Places API Web Service.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM