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

    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.

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