Skip to content

Instantly share code, notes, and snippets.

@DylanCodeCabin
Created March 1, 2023 06:02
Show Gist options
  • Save DylanCodeCabin/4eaab8533ec0feb8a9bdb71589ab046a to your computer and use it in GitHub Desktop.
Save DylanCodeCabin/4eaab8533ec0feb8a9bdb71589ab046a to your computer and use it in GitHub Desktop.
/* Restrict autocomplete to more than one country
*
* In this case: Republic of Ireland and United Kingdom
*/
jQuery(($) => {
WPGMZA.AddressInput.prototype.loadGoogleAutocomplete = function(){
/* UK + Repuclic of Ireland */
const countries = ['ie', 'gb'];
if(WPGMZA.settings){
if(WPGMZA.settings.googleMapsApiKey || WPGMZA.settings.wpgmza_google_maps_api_key){
if(WPGMZA.isGoogleAutocompleteSupported()) {
this.element.googleAutoComplete = new google.maps.places.Autocomplete(this.element, this.options);
this.element.googleAutoComplete.setComponentRestrictions({country: countries});
}
this.googleAutocompleteLoaded = true;
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment