Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1039062

    Is there a recommended method of tying into the aviaOnGoogleMapsLoaded callback that is triggered once the Google Map API has finished loading?

    #1039336

    Hey Switzer,

    Well, you need to write a custom script that will listen to that event and add a function to handle it.

    If you need further assistance please let us know.
    Best regards,
    Victoria

    #1040212

    exactly, so which type of event would this be?
    Maybe a little example of how the event listener should be constructed?

    Would this be the recommended way:

    (function($){
        $('body').on('av-google-maps-api-loaded', my_callback() );
    
        function my_callback(){
            console.log('hey dude');
        }
    })( jQuery );
    

    or maybe better to use the avia-google-maps-api-script-loaded event?:

    $('body').on('avia-google-maps-api-script-loaded', my_second_callback() );
    function my_second_callback(){
       console.log('phone is ringing, dude');
    }

    Update 1: Neither. Now using something like:

    window.addEventListener('load',function(){
            if(document.getElementById('av_gmap_0')){
                gmap_init();
            }
    });

    But again, not sure if this is the recommended method, also there is no way to provide a unique ID to the map, so we just have to check if at least one map exists.

    Update 2: Nope, also not the best way.

    • This reply was modified 5 years, 11 months ago by SwitzerBaden. Reason: Added addEventListener option
    #1041624

    Hi,

    Have you tried using “DOMContentLoaded” instead of “load”? You can put the map inside a color section and then add a Section ID or apply a custom css class attribute to the map element itself.

    // https://kriesi.at/documentation/enfold/intro-to-layout-builder/#turn-on-custom-css-class-field-for-all-alb-elements

    Best regards,
    Ismael

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.