-1

If I select something from my text fields drop down list that autocomplete has provided which includes city, state, and country the results come back fine. But if I don't use one of the drop down list autocomplete items and I just type in 'San Francisco' and press enter autocomplete.place() is undefined. I would like to have similar functionality to www.airbnb.com where I only have to type in 'San Francisco' and it still finds everything in the city without needing to type in state and country.

Here are my input parameters.

var input = document.getElementById('location');
var options = {
types: ['(cities)'],
componentRestrictions: { country: "us" }
};
//input = "San Francisco" => places = undefined
var autocomplete = new google.maps.places.Autocomplete(input, options);
var place = autocomplete.getPlace();
chuckd
  • 13,460
  • 29
  • 152
  • 331

2 Answers2

1

It's not works only with cities.The places autocomplete works other things. Here is a link of correct examples and documentation. http://www.w3docs.com/learn-javascript/places-autocomplete.html

Hazarapet Tunanyan
  • 2,809
  • 26
  • 30
1

Maybe for this reason:

types: ['(cities)'],

if you remove that or specify what you really want...

Eloy Fernández Franco
  • 1,350
  • 1
  • 24
  • 47