-1

I am using Google's Place Api for getting a list of places from the string searched from a end user. But i want to remove the country name from the suggestion coming as well as from list of responses for a address.

how can i achieve this in android ?

enter image description here

Punit Sharma
  • 2,951
  • 1
  • 20
  • 35

2 Answers2

0

You have Code like below. What ever you don't need just remove it.

String address = addresses.get(0).getAddressLine(0);
String city = addresses.get(0).getLocality();
String state = addresses.get(0).getAdminArea();
String country = addresses.get(0).getCountryName();
String postalCode = addresses.get(0).getPostalCode();
-1

You appears to be using the Javascript version of the Google Places API. Let me know if I've guessed incorrectly!

All you need to do is add &region=US when you load the Google Maps API. E.g.:

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places&region=US">

Note that this will still show the country for Autocomplete predictions outside of the United States (which helps disambiguate "Paris, TX" from "Paris, France").

See the section on Region localization in the Google Maps APIs documentation for more details on this parameter.

If you need even more control over the appearance, you can use the AutocompleteService programmatic API to build your own UI, rather than using the Autocomplete control.

spiv
  • 2,458
  • 1
  • 16
  • 20
  • No, I am using place api's android version !! and Secondly i want to remove the country name from suggestion as well as result list. – Punit Sharma May 17 '16 at 05:03
  • Ah, I got the wrong idea from your image. In that case I think your only option currently is to use the programmatic API (GeoDataApi.getAutocompletePredictions) rather than the pre-built widgets, so you can adjust the results before showing them to the user. But that's obviously going to be a lot more work, sorry :( – spiv May 17 '16 at 07:38
  • ok tnx, that means i need to manage the results and process them and then show .. – Punit Sharma May 17 '16 at 08:35