Skip to Content
Menu

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?

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