Google map not loading

This topic contains 4 replies, has 2 voices, and was last updated by  Christian 11 years, 9 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #3354

    Hi
    I updated to eo version 1.7 and now I’m facing the problem that the google map on the venue page is not displayed anymore.

    I tried to change the template code from
    do_shortcode(…) to eo_get_venue_map(…) and
    I removed my template and used the eo default template -> but it is still not working

    I’m new in using wordpress, but I was looking into your code and I found this in event-organiser-register.php:

    wp_register_script( ‘eo_GoogleMap’, $protocal.’maps.googleapis.com/maps/api/js?sensor=false&callback=eo_load_map&language=’.substr(get_locale(),0,2));

    If I understand it right, the registered javascript should load in the page header section. Using Firebug in Firefox I tried to find it in the DOM, but I’m not able to find this code. So I think this can be the problem, since this script should call eo_load_map, which is definitly not called (I added a js alert command, and nothing appears on page load).

    please help.

    You can take a look at the page here: http://www.villakunterbunt-eisenstadt.at/?event-venue=generationenzentrum-eisenstadt

    Christian
    #3361

    The script is registered there, but should actually be enqueued in the footer of the page. The shortcode handler ( https://github.com/stephenharris/Event-Organiser/blob/master/classes/class-eventorganiser-shortcodes.php) enqueues it using the print_scripts method. (See this line).

    That part of the code is being called (because its prints stuff like the venue latitude/longitude for use by the map – and I can see that in the footer of the page). Specifically the conditional here should be true for the same reason (though check it just in case).

    If that is the case the problem lies with wp_enqueue_script() not printing that script (I’m afraid I have no idea why). You can try disabling other plug-ins temporarily, but it seems odd that it would effect just that one. (All other scripts are correctly printed to the footer).

    You could use var_dump() to see if the Google maps script is present in global $wp_scripts; (it should be!). If its not, then you could register it just before you enqueue – but I’d like to work out why it isn’t registered at that point…

    Stephen Harris
    #3362

    Sorry I can’t be of much help – its a very odd bug – doesn’t seem to be any good reason for it, and I can’t duplicate it on my test sites. I’ll be happy to help with further debugging, so let me know how the above goes!

    Stephen Harris
    #3373

    Hi stephen

    Thanks for your fast reply. I created a test site and disabled the “Comprehensive Google Map Plugin” (http://wordpress.org/extend/plugins/comprehensive-google-map-plugin/) which I’m using on my site (but not on the event pages) and then it works!

    Since I want to use both plugins, i will continue my investigation on that problem. If you have any ideas you’re welcome

    Christian
    #3375

    So this is my investigation result: “Comprehensive Google Map Plugin” functions.php contains code to remove duplicated google maps js loading:


    if ( !function_exists('cgmp_google_map_deregister_scripts') ):
    function cgmp_google_map_deregister_scripts() {
    $handle = '';
    global $wp_scripts;

    if (isset($wp_scripts->registered) && is_array($wp_scripts->registered)) {
    foreach ( $wp_scripts->registered as $script) {

        if (strpos($script->src, 'http://maps.googleapis.com/maps/api/js') !== false && $script->handle != 'cgmp-google-map-api') {
    
            if (!isset($script->handle) || $script->handle == '') {
                $script->handle = 'remove-google-map-duplicate';
            }
    
            unset($script->src);
            $handle = $script->handle;
    
            if ($handle != '') {
                $wp_scripts->remove( $handle );
                $handle = '';
                break;
            }
        }
    }
    

    }

    } endif;

    So I added the following in the venue template to disable the deregister code on venue pages:


    remove_action('wp_head', 'cgmp_google_map_deregister_scripts', 200);
    get_header();

    NOTE:The remove_action call has be added before the get_header call !!!

    I’m happy again 🙂

    Christian
Viewing 5 posts - 1 through 5 (of 5 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.