Skip to Content
Menu

placeLookup()

Attempt to look up a business by Place ID via Google Maps Place Service.

JavaScript February 7, 2021

Usage

JavaScript
placeLookup(placeID)

Parameters

placeID
(Required) (String) The place ID to look up.
Default: None

Request or provide clarification »

Examples

Called after a successful (and accurate) address lookup from Google Maps.

JavaScript
placeLookup(results[0].place_id);

Additional Notes

This function triggers placeSuccess on success when the nebula.session.geolocation.address.place object can be used.

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

    No Hooks

    This function does not have any filters or actions available. Request one?
    JavaScript
    nebula.placeLookup = function(placeID){
        if ( google?.maps?.places ){
            let service = new google.maps.places.PlacesService(jQuery('<div></div>').get(0));
            service.getDetails({
                placeId: placeID
            }, function(place, status){
                if ( status === google.maps.places.PlacesServiceStatus.OK ){
                    if ( typeof place.name !== 'undefined' ){
                        nebula.session.geolocation.address.place = {
                            id: placeID,
                            name: place.name,
                            url: place.url,
                            website: place.website,
                            phone: place.formatted_phone_number,
                            ratings: {
                                rating: place.rating,
                                total: place.user_ratings_total,
                                reviews: ( typeof place.reviews !== 'undefined' )? place.reviews.length : 0,
                            },
                            utc_offset: place.utc_offset,
                        };
    
                        sessionStorage['nebulaSession'] = JSON.stringify(nebula.session);
                        nebula.dom.document.trigger('placeSuccess');
                    }
                }
            });
        }
    };

    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

    For non-module import functions:

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


    For dynamically imported module function overrides:

    jQuery(window).on('load', function(){
        nebula.placeLookup = function(placeID){
            //Write your own code here, leave it blank, or return false.
        }
    });


    Custom Nebula DOM events do also exist, so you could also try the following if the Window Load listener does not work:

    jQuery(document).on('nebula_module_loaded', function(module){
        //Note that the module variable is also available to know which module specifically was imported
        if ( typeof nebula.placeLookup === 'function' ){
            nebula.placeLookup = function(placeID){
                //Write your own code here, leave it blank, or return false.
            }
    	}
    });