Hi :),
I want to limit search results to countries in Europe and to cities (remove searching for companies, restaurants etc.)
I know, that google.maps.places.ComponentRestrictions
- link, could be helpful.
Google Docs suggest to use componentRestrictions: [country: 'us']
, and placed in getPlacePredictions
, but is not working.
/* global google */
let autocompleteService = null;
let placesService = null;
// SEARCH CITY ONLY IN USA
// var options = {
// componentRestrictions: { country: ['us'] },
// types: ['city'],
// };
const getSuggestions = async search => {
if (
!autocompleteService &&
window.google &&
window.google.maps &&
window.google.maps.places
) {
autocompleteService = new google.maps.places.AutocompleteService();
}
if (!autocompleteService) {
return [];
}
return new Promise((resolve, reject) => {
autocompleteService.getPlacePredictions(
{ input: search },
(data, status) => {
if (status === google.maps.places.PlacesServiceStatus.OK) {
resolve(data);
} else {
reject(status);
}
}
);
});
};
Thank you for your time.