Created
March 1, 2023 06:02
-
-
Save DylanCodeCabin/4eaab8533ec0feb8a9bdb71589ab046a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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