Tagged: event listener, Google map API
Is there a recommended method of tying into the aviaOnGoogleMapsLoaded callback that is triggered once the Google Map API has finished loading?
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
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.
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.
Best regards,
Ismael