'google is not defined' console error and site hangup upon loading any events pg

Home Forums Calendar Products Events Calendar PRO 'google is not defined' console error and site hangup upon loading any events pg

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1185823
    Keri
    Participant

    So, any time I try to load an events page (any view at all), there is a major site hangup and a console error:

    Uncaught ReferenceError: google is not defined

    Looks like it is trying to call Google Maps objects within this file: tribe-events-ajax-maps.min.js
    Things I have tried to resolve this issue:

    • Enqueue the google maps script within my functions.php with my API key whenever other scripts are loaded
    • Enqueue the google maps script within my functions.php with my API key when init is fired
    • Swapping to default themes and deactivating other plugins
    • Reinstalling and updating to the latest versions of Events Calendar PRO

    Also, take note of the following

    • I am using the latest version of the Jupiter theme
    • Sometimes when I perform the steps above, the error will be bypassed and the page and maps will be loaded, but only for a limited time.
    • This error ONLY occurs when I have the Events Calendar PRO plugin activated.
    • I have my API key set within the plugin options (I also have an option to include it within my Theme Options as well.

    I’ve been trying to find a stable solution or a workaround to this for quite some time now. Perhaps there is some code somewhere in the resources for the plugin that loads the Google Maps script incorrectly?

    Please help! Thanks in advance.

    #1186077
    Andras
    Keymaster

    Hi Keri,

    Thanks for going Pro and welcome to the forums!

    Also thanks for the detailed testing and descriptions, that will help us to start faster.

    I see that you did a lot of test. I would like to ask you to do a conflict testing based on this guide:

    Testing Conflicts With Themes and Other Plugins

    And also, only input your Google Map API key under Events > Settings > APIs.

    Please let me know the results and we’ll take it from there.

    Cheers,
    Andras

    #1186948
    Keri
    Participant

    Andras,

    Thanks for the quick response.
    I went through the conflict testing process you provided me and as soon as I reverted to the default theme, deactivated all non-tribes plugins, and cleared my browser cache, the problem was resolved. Then, I reactivated each plugin one-by-one and reactivated my original theme and the issue seemed to have been resolved initially; no console errors.

    However, after about 15-20 minutes, the issue arose again; got the same console error and site hangup. I had done nothing except refresh the page! So, I went through the conflict testing process once more and even after completing the three steps under ‘Test if there is a conflict’, the issue was still present this time. I also tried to deactivate and re-activate the Events Calendar plugins and tried again, to no avail; still the same error.

    There has to be some back-end script that is enqueuing and loading the Google Maps script in maybe a deprecated fashion? That would be my only guess. What else can I do? 🙁

    Thanks.

    • This reply was modified 9 years, 6 months ago by Keri.
    #1187426
    Andras
    Keymaster

    Hi Cary,

    Thanks for doing the testing. I’m sorry to hear the issue came back. It’s weird that it didn’t disappear in the second run.

    So in the second run you again switched to twentysixteen and deactivated everything, if I understand correctly. Did you test after you also deactivated our plugins? Basically running only WordPress. If not please check that as well: twentysixteen and no plugins.

    If all is good, then activate first only The Events Calendar and browse around a bit to see if the error comes back. This will help us determine whether TEC already causes the issue, or maybe there is something in your WP settings or install or server or something else that can cause this.

    Then activate the Pro…

    Please try to mark down what exactly you were doing when the error appears. Which page you were on, where you were clicking.

    Could you also share with me on which page you are experiencing this? Thanks!

    Cheers,
    Andras

    #1188710
    Keri
    Participant

    Hi Andras,

    I am still working on pinpointing the cause of this error. I did some conflict testing today and results varied. I don’t have the time to lay everything out right now; I just wanted to reply to this thread to keep it from closing. I will get back to you soon. Bear with me!

    Thanks.

    #1189312
    Keri
    Participant

    Andras,

    I think I may have found the issue, albeit unconventionally!

    I was doing some digging in the TEC PRO code and I found where the Google Maps API script is generated and loaded in Ajax_Maps.php and I noticed these lines in the handle() function:

    $http = is_ssl() ? 'https' : 'http';
    $url  = apply_filters( 'tribe_events_pro_google_maps_api', $http . '://maps.google.com/maps/api/js' );
    wp_register_script( 'tribe-gmaps', $url, array( 'tribe-events-pro' ) );

    It looks like the script is being loaded based on the security protocol of the site where the plugin is being operated (my site is run with no SSL cert as of now: HTTP). However, after doing a bit of research, I found that Google recommends loading the Maps JavaScript API over HTTPS regardless, in accordance with their current security efforts. So, I tried modifying the code like so:

    $http = 'https'; /*is_ssl() ? 'https' : 'http';*/

    After applying this change, the error has disappeared, I’m assuming since the script is being loaded securely.

    Additionally, the article I provided above also states that if you NEED to load the script through HTTP for whatever reason, it says to use the URL ‘http://maps.googleapis.com/’ instead of the default one found in the code. I also tried this and found that it still throws the error, but loads the page successfully anyway. Interesting.

    So, it seems that there wasn’t any plugin/theme conflicts after all. Let me know if this is a valid fix or not 🙂
    Thanks for the help!

    #1189331
    Andras
    Keymaster

    Hi Keri,

    WOW!!! First, thanks for getting back to me on that!

    Second, WOW! 🙂 Thanks for going the extra mile and sharing the results. Great find!

    Please hang in there while I run this through our developers. I’ll get back to you soon.

    Cheers,
    Andras

    #1189376
    Andras
    Keymaster

    Hello again,

    I checked with one of the developers and he also recommended to use only the secure connection. So your workaround is perfect for that. 🙂

    I am going to close this ticket, but if you need anything else related to this topic or another please post a new topic on the forum and we can help you out.

    Cheers,
    Andras

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘'google is not defined' console error and site hangup upon loading any events pg’ is closed to new replies.