Aamir Rind
Aamir Rind

Reputation: 39699

Google Places Auto-Complete

The input box is initialized properly but it is not generating any suggestions. Can any one point out what I am doing wrong? Here is the code.

Update

I have investigated the issue. The problem is in the line:

types: ['(cities)', '(regions)']

when I specify only one type types: ['(cities)'] no matter region or cities it works. But two types are not working together. Although the documentation clearly says that types are Array of strings and valid values are 'establishment', 'geocode', '(regions)' and '(cities)'

Upvotes: 8

Views: 12191

Answers (3)

Christina.Codes
Christina.Codes

Reputation: 88

As Chris mentioned, there is currently no way to get results for multiple place types. However, you can call the API twice with different place types and populate a map (or whatever you're building) with both types. For example:

var request1 = {
  location: event.latLng,
  radius: 8047,
  types: ['cafe'],
};
var request2 = {
  location: event.latLng,
  radius: 8047,
  types: ['library'],
};

Upvotes: 2

Chris Green
Chris Green

Reputation: 4425

As mentioned in the documentation:

"types, which can either specify one of two explicit types or one of two type collections."

This means that the types array only supports one parameter.

If you think it would be a useful feature to support more than one parameter or a mixture of explicit types and collections, please file a Places API - Feature Request.

Upvotes: 9

geocodezip
geocodezip

Reputation: 161394

There are no results of type (cities)' or '(regions)'. If I change the types array to ['establishment'], I get results.

Working example

If you use only one type, it works:

Example

Upvotes: 0

Related Questions