Skip to Content


Actually queries the Google Maps address API.

JavaScript February 7, 2021


This function runs automatically, so it is not called manually. Is this incorrect?


Demo file is missing! Please report this error.

Additional Notes

Instead of calling this function directly, please use nebulaAddressAutocomplete() so that the Google Maps library can be loaded as needed.

Was this page helpful? Yes No

    A feedback message is required to submit this form.

    Please check that you have entered a valid email address.

    Enter your email address if you would like a response.

    Thank you for your feedback!

    Source File

    Located in /assets/js/modules/location.js on line 34.

    No Hooks

    This function does not have any filters or actions available. Request one?
    nebula.googleAddressAutocompleteCallback = function(autocompleteInput, uniqueID = 'unnamed'){
        window[uniqueID] = new google.maps.places.Autocomplete(
            {types: ['geocode']} //Restrict the search to geographical location types
        google.maps.event.addListener(window[uniqueID], 'place_changed', function(){ //When the user selects an address from the dropdown, populate the address fields in the form.
            let place = window[uniqueID].getPlace(); //Get the place details from the window[uniqueID] object.
            let simplePlace = nebula.sanitizeGooglePlaceData(place, uniqueID);
            let thisEvent = {
                category: 'Contact',
                action: 'Autocomplete Address',
                intent: 'Intent',
                place: place,
                simplePlace: simplePlace
            nebula.dom.document.trigger('nebula_address_selected', [place, simplePlace, jQuery(autocompleteInput)]);
            nebula.dom.document.trigger('nebula_event', thisEvent);
            ga('set',, thisEvent.action);
            ga('send', 'event', 'Contact', 'Autocomplete Address', + ', ' + simplePlace.state.abbr + ' ' +;
            nebula.crm('identify', {
                'street_number': simplePlace.street.number,
                'street_full': simplePlace.street.full,
                'county': simplePlace.county,
                'address': simplePlace.street.full + ', ' + + ', ' + simplePlace.state.abbr + ' ' +
        jQuery(autocompleteInput).on('focus', function(){
            if ( === 'https' && navigator.geolocation ){
                navigator.geolocation.getCurrentPosition(function(position){ //Bias to the user's geographical location.
                    let geolocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
                    let circle = new google.maps.Circle({
                        center: geolocation,
                        radius: position.coords.accuracy
        }).on('keydown', function(e){
            if ( e.key === 'Enter' && jQuery('.pac-container:visible').length ){ //Prevent form submission when enter key is pressed while the "Places Autocomplete" container is visbile
                return false;
        if ( autocompleteInput === '#address-autocomplete' ){
            nebula.dom.document.on('nebula_address_selected', function(){
                //do any default stuff here.


    To override or disable this JavaScript function, simply redeclare it with the exact same function name.

    nebula.googleAddressAutocompleteCallback = function(){
        //Write your own code here, leave it blank, or return false.