we are currently using Sitecore 9.0.2 with SXA 1.8.1
Is there a way to limit the Auto-complete on the Location finder to a particular country or city?
Sitecore Stack Exchange is a question and answer site for developers and end users of the Sitecore CMS and multichannel marketing software. It only takes a minute to sign up.
Sign up to join this communityFor a project I worked on we created a custom Maps Connector theme. We copied the script provided OOTB with SXA, renamed it, then made some changes to it.
Here is an example of how we changed it so the country was included:
autocomplete.getPlacePredictions({
input: queryParams.text,
'componentRestrictions': {
'country': 'us'
},
'types': ['geocode']
}, function(results) {
var predictions = [],
length;
if (results != null && results.length) {
length = results.length >= maxResults ? maxResults : results.length;
for (var i = 0; i < length; i++) {
predictions.push(_.extend(results[i], {
text: results[i].description
}));
}
console.log("Adding predictions to storage.");
sessionStorage.setItem(key, JSON.stringify(predictions));
successCallback(predictions);
} else {
failCallback();
}
});