Reputation: 159
I am using Google API for auto complete suggestions. I am getting all results from Google service.Now I need only CITY STATE and COUNTRY in suggestion and not the whole address of a place.I had referred the developer guide where I get to know, we can restrict suggestion with Places Type. See this link https://developers.google.com/places/supported_types. I am not getting how to set this Type for my suggestion. Please help.
Upvotes: 0
Views: 371
Reputation: 9246
After getting json response from GooglePlace API, format it accordingly as per city,state,country
As per google docs:----
When the Places service returns results from a details request, it places them within a single result. Each result may contain the following fields:
address_components[] is an array of separate address components used to compose a given address. For example, the address "111 8th Avenue, New York, NY" contains separate address components for "111" (the street number, "8th Avenue" (the route), "New York" (the city) and "NY" (the US state). Each address_component typically contains:
types[] is an array indicating the type of the address component.
long_name is the full text description or name of the address component.
short_name is an abbreviated textual name for the address component, if available. For example, an address component for the state of Alaska may have a long_name of "Alaska" and a short_name of "AK" using the 2-letter postal abbreviation.
formatted_address is a string containing the human-readable address of this place. Often this address is equivalent to the "postal address," which sometimes differs from country to country. This address is generally composed of one or more address_component fields.
Upvotes: 1