Skip to Content

requestPosition()

Use the Google Maps API to request the user’s geolocation.

JavaScript February 7, 2021

Usage

JavaScript
 requestPosition()

Parameters

This function does not accept any parameters. Is this incorrect?

Source File

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

No Hooks

This function does not have any filters or actions available. Request one?
JavaScript
function requestPosition(){
    if ( google?.maps ){
        nebula.loadJS('https://www.google.com/jsapi?key=' + nebula.site.options.nebula_google_browser_api_key, 'google-maps').then(function(){ //May not need key here, but just to be safe.
            google.load('maps', '3', {
                other_params: 'libraries=placeskey=' + nebula.site.options.nebula_google_browser_api_key,
                callback: function(){
                    nebula.getCurrentPosition();
                }
            });
        });
    } else {
        getCurrentPosition();
    }
}

Override

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

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