Restrict Google Places Autocomplete to return addr

2020-06-07 05:22发布

问题:

autocomplete = new google.maps.places.Autocomplete(input, { types: ['geocode'] });

returns streets and cities amongst other larger areas. Is it possible to restrict to streets only?

回答1:

I think what you want is { types: ['address'] }.

You can see this in action with this live sample: https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete (use the "Addresses" radio button).