0

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?

1
  • No, there is no such possibility. – Dawid Rutkowski Jun 5 '19 at 15:11
6

For 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();
    }
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.