• Resolved Adam Patterson

    (@adampatterson)


    I’m getting a 404 google is not defined

    The generated URL is:
    https://maps.google.com/maps/api/js/?language=en&region=ca&key=my_key&libraries=places&v=3.36&ver=2.2.231

    If I add the following:

    add_filter( 'wpsl_gmap_api_params', 'custom_gmap_api_params' );
    function custom_gmap_api_params( $api_params ) {
       $api_params = $api_params .'&key=TEST';
    
        return $api_params;
    }

    I can confirm that the query string is modified, and this is the path from the plugin.

    I looked into the API path and it should be.

    https://maps.googleapis.com/maps/api/js and not https://maps.google.com/maps/api/js/

    Change google.com to googleapis.com and remove the trailing slash after js/

    This fix needs to be applied to the class-admin.php

    Loog for and change:
    wp_enqueue_script( ‘wpsl-gmap’, ( ‘//maps.google.com/maps/api/js/’ . wpsl_get_gmap_api_params( ‘browser_key’ ) ), false, WPSL_VERSION_NUM, true );

    to

    wp_enqueue_script( 'wpsl-gmap', ( '//maps.googleapis.com/maps/api/js' . wpsl_get_gmap_api_params( 'browser_key' ) ), false, WPSL_VERSION_NUM, true );

    Hope this can be updated soon! ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tijmen Smit

    (@tijmensmit)

    The issue is not the Google Maps library path ( both work, but it should indeed be changed ), but the trailing slash that’s added for some reason on your server after ‘js’.

    It’s not present in the code, so not sure yet how it ends up in the path in the first place, but will look into it.

    Thread Starter Adam Patterson

    (@adampatterson)

    Thanks for the reply,

    Is there an update that maybe isn’t pushed? I have 2.2.231 installed on WordPress 5.2.4.

    And you are correct, both paths work without the trailing slash.

    I found the slash in class-admin.php but I don’t see it in your source ???♂?.

    https://plugins.trac.www.ads-software.com/browser/wp-store-locator/tags/2.2.231/admin/class-admin.php#L423

    Thread Starter Adam Patterson

    (@adampatterson)

    I checked my local history in the Editor and I accidentally placed the trailing slash.

    My theme stripped version tags from assets and thus it removed the API key from the Google Maps enqueued script.

    I placed /here in the path to see if I was in the correct location and when only removed here.

    Sorry for the trouble ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘google is not defined ( 404 )’ is closed to new replies.