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. Jun 5, 2019 at 15:11

1 Answer 1

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 and acknowledge that you have read and understand our privacy policy and code of conduct.

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