is it possible to restrict the autocomplete search only to cities and postal code?
This won't work:
autocomplete = new google.maps.places.Autocomplete(
/** @type {!HTMLInputElement} */(document.getElementById('autocomplete')),
{types: ['(cities', '(postal_code)'], componentRestrictions: {country: "de"}});
Maybe this is right?
autocomplete = new google.maps.places.Autocomplete(
/** @type {!HTMLInputElement} */(document.getElementById('autocomplete')),
{types: ['(regions)'], componentRestrictions: {country: "de"}});
Source: https://developers.google.com/places/supported_types
But autocomplete also show some results outside my restricted country, why?

Some suggestions?
Solution
autocomplete = new google.maps.places.Autocomplete(
/** @type {!HTMLInputElement} */(document.getElementById('autocomplete')),
{types: ['(regions)'], componentRestrictions: {'country': "de"}});
The code below is the correct answer to my question.
autocomplete = new google.maps.places.Autocomplete(
/** @type {!HTMLInputElement} */(document.getElementById('autocomplete')),
{types: ['(regions)'], componentRestrictions: {'country': "de"}});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With