WordPress.org

Ready to get started?Download WordPress

Forums

WP Flexible Map
[resolved] Error on update: API request rejected (12 posts)

  1. WebbyMerlin
    Member
    Posted 1 year ago #

    Just updated to 1.6.0 and now pages with maps serve me a pop up (and no map) saying:

    The Google Maps API server rejected your request. The "sensor" parameter specified in the request must be set to either "true" or "false".

    OK

    http://wordpress.org/extend/plugins/wp-flexible-map/

  2. webaware
    Member
    Plugin Author

    Posted 1 year ago #

    G'day, can you provide a link please? Also, what version of WordPress are you running?

    cheers,
    Ross

  3. webaware
    Member
    Plugin Author

    Posted 1 year ago #

    Also, which web browser / version please...

  4. WebbyMerlin
    Member
    Posted 1 year ago #

    Running WP 3.5 - here's a page:
    http://108.167.155.21/~gig3/author/sugarinthegourd/

    Using Chrome Version 23.0.1271.97 m
    or IE Version 9.0.8112.16421

  5. webaware
    Member
    Plugin Author

    Posted 1 year ago #

    G'day,

    The plugin is registering this script to load:

    http://maps.google.com/maps/api/js?v=3.10&sensor=false

    but your website is loading this script:

    http://maps.google.com/maps/api/js

    I can think of two reasons why this might happen.

    1. Your website already has a script registered as 'google-maps', and it's loading that one; and it's wrong.

    Fix: edit the file /wp-content/plugins/wp-flexible-map/class.FlxMapPlugin.php and change line 42 from this:

    add_action('wp_enqueue_scripts', array($this, 'actionEnqueueScripts'));

    to this:

    add_action('init', array($this, 'actionEnqueueScripts'), 1);

    If that fixes the problem, then you have something else in your website that is registering the maps API and you should try to remove it (or get the author to fix it).

    2. Your website has something that is messing with the registered scripts and stripping off everything after and including the '?'

    Fix: disable all other plugins and see if that fixes it. If not, then switch the theme to twenty{ten|eleven|twelve} and see if that fixes it.

    Let me know if either of those things fix the problem, and we can then try to narrow things down.

    cheers,
    Ross

  6. webaware
    Member
    Plugin Author

    Posted 1 year ago #

    Looking at your page source, you definitely have something there that is stripping all parameters off script URIs from '?' onwards. This is bad! I've seen this recommended in some dodgy blog posts somewhere, and it's very bad behaviour. Somebody needs a good spanking for doing that!

    You need to determine what's doing that on your website, and kill it.

    cheers,
    Ross

  7. WebbyMerlin
    Member
    Posted 1 year ago #

    I updated the add_action line first, with no change in results. Disabled all the plugins, no change, switched themes.. and it worked! I re-enabled all the plugins and it still works in the Twenty Twelve theme. Alas, I can't use that theme, I need to use Tersus. Before you updated to 1.6.0 and had to pass "sensor", it worked fine, have been seeing maps without issue while working on other aspects of the pages, it didn't quit until I ran the update this evening. Is there some other way for you to pass the sensor indicator to that Google API?

    I also tried putting it in the call like this:
    [flexiblemap width=600 height=400 title=”Test Title” address=”Santa Monica CA 90401″ sensor="false" scrollwheel=”true”]

    Here it is on this test page (no joy):
    http://108.167.155.21/~gig3/test-page-for-flexible-map-code-v-1-6-0-on-wp-3-5/

  8. webaware
    Member
    Plugin Author

    Posted 1 year ago #

    The problem is that your theme has some code that is stripping script URLs of all URL parameters, i.e. from '?' onwards. It's a function in your theme.

    The only reason it was working before was that I wasn't using the standard WordPress way to register scripts, I was directly writing the scripts in the page footer. IOW, the old version used to write exactly the same script URL as the new one should be, but your theme is chopping it off at '?' and stopping it from working.

    It looks like you're using a child theme of the Tersus theme. Did you write it, or did someone write it for you? Does it / Tersus have any options about script versions, and can you turn that off?

  9. WebbyMerlin
    Member
    Posted 1 year ago #

    The Tersus theme comes with a built in child theme that incorporates all the main Tersus theme and then easily lets you make changes to styles and still keep the core intact. It has a ton of options but nothing about script versions. I do have the PHP-Exec plugin installed so i can do <?php do shortcode ... and other straight PHP code in widgets, pages, posts, custom post types etc. and that all works great, some with &arguments tacked on there. Could there be a way to call this with native php in some way? I can also put code also into header and footers of pages as part of the theme for things like Adsense code and Analytics... there must be some way to get my maps back!

    Tersus is a responsive theme made by NorthVantage.

  10. webaware
    Member
    Plugin Author

    Posted 1 year ago #

    You will need to speak with NorthVantage and send them a link to this thread, so that they can see what they've done. They will need to fix it.

    In the meantime, here's a dirty hack that will get your website working again. Add it to the functions.php file in your theme (either the parent or the child, doesn't matter). Let me know if it doesn't get you working again.

    function emergency_fix_gig_maps() {
        // remove Google Maps script badly hacked by naughty theme
        wp_dequeue_script('flxmap');
        wp_dequeue_script('google-maps');
    
        // directly write the Google Maps script
        $protocol = is_ssl() ? 'https' : 'http';
        $url = "$protocol://maps.google.com/maps/api/js?v=3.10&sensor=false";
        echo "<script src='$url'></script>\n";
    
        // directly write the Flexible Maps script
        $url = plugin_dir_url('wp-flexible-map/x') . '/flexible-map.min.js?ver=1.6.0';
        echo "<script src='$url'></script>\n";
    }
    add_action('wp_footer', 'emergency_fix_gig_maps', 1);

    cheers,
    Ross

  11. WebbyMerlin
    Member
    Posted 1 year ago #

    YOU FIXED IT! WOO HOOO... yes that did it.. put it in the child theme and tried the test page above and there's my map!

    Now where else on the planet can you get service like this at 3:45 AM in the MORNING! LOL

    Thanks so much.. YOU ROCK!

  12. webaware
    Member
    Plugin Author

    Posted 1 year ago #

    Excellent, good work. Must be time for a small glass with a large Bourbon then :)

    Oh, and it's almost 8pm here (Down Under). I hope you can get some sleep now!

    cheers,
    Ross

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic