Skip to Content
Menu

geoErrorCallback()

Stored geolocation error information when they occur.

JavaScript February 7, 2021

Usage

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

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 265.

    No Hooks

    This function does not have any filters or actions available. Request one?
    JavaScript
    function geoErrorCallback(error){
        let geolocationErrorMessage = '';
        let geoErrorNote = '';
    
        switch ( error.code ){
            case error.PERMISSION_DENIED:
                geolocationErrorMessage = 'Access to your location is turned off. Change your settings to report location data.';
                geoErrorNote = 'Denied';
                break;
            case error.POSITION_UNAVAILABLE:
                geolocationErrorMessage = "Data from location services is currently unavailable.";
                geoErrorNote = 'Unavailable';
                break;
            case error.TIMEOUT:
                geolocationErrorMessage = "Location could not be determined within a specified timeout period.";
                geoErrorNote = 'Timeout';
                break;
            default:
                geolocationErrorMessage = "An unknown error has occurred.";
                geoErrorNote = 'Error';
                break;
        }
    
        nebula.session.geolocation = {
            error: {
                code: error.code,
                description: geolocationErrorMessage
            }
        };
    
        nebula.dom.document.trigger('geolocationError');
        nebula.dom.body.addClass('geo-error');
        gtag('event', 'exception', {
            message: '(JS) Geolocation error: ' + geolocationErrorMessage,
            fatal: false
        });
        nebula.crm('event', 'Geolocation Error');
    }
    

    Override

    To override or disable this JavaScript function, simply redeclare it with the exact same function name. Remember: Some functionality is conditionally loaded via dynamic imports, so if your function is not overriding properly, try listening for a DOM event (described below).

    JavaScript
    function geoErrorCallback(){
        //Write your own code here, leave it blank, or return false.
    }