Unyson icon indicating copy to clipboard operation
Unyson copied to clipboard

Map shortcode stopped working

Open dk-wordpress opened this issue 10 years ago • 41 comments

Hello!

I have noticed that Map Shortcode just stopped working with a following error in console:

Google Maps API error: Google Maps API error: MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error

MissingKeyMapError The script element that loads the API is missing the required authentication parameter. If you are using the standard Maps JavaScript API, you must use a key parameter with a valid API key. If you are a Premium Plan customer, you must use either a client parameter with your client ID or a key parameter with a valid API key.

See the guide to API keys and client IDs.

is there any way to fix this problem? Thank you

dk-wordpress avatar Jun 23 '16 12:06 dk-wordpress

a screenshot of Alert from Contacts page sc

dk-wordpress avatar Jun 23 '16 12:06 dk-wordpress

It works on my side

ghost avatar Jun 23 '16 12:06 ghost

I think they introduced some requests limitations and you reached the limit, to prevent that you will need to create an account and insert somewhere the API key

Trouble...

ghost avatar Jun 23 '16 12:06 ghost

yes, it works fine on my test installation too, but this site is not working http://johnsonshomebuilding.co.uk/contact-us/

i can provide you WP admin access if needed

dk-wordpress avatar Jun 23 '16 12:06 dk-wordpress

i think so...

dk-wordpress avatar Jun 23 '16 12:06 dk-wordpress

@moldcraft Also getting this errors, but it works.

What about adding a notice to the user that will say he needs to enter their Google API credentials? Somewhere in the shortcodes extension settings.

andreiglingeanu avatar Jun 24 '16 09:06 andreiglingeanu

https://developers.google.com/maps/documentation/javascript/usage

ghost avatar Jun 24 '16 09:06 ghost

Same here. Also a popup displayed

Ataurr avatar Jun 25 '16 09:06 Ataurr

Hi) Please help. I have the same problem. fire On this site map shortcode isn't working.

What should I do? How to solve this issue? If I need API keys where should I add them?

Please help, many of my clients have already complained that map doesn't work.

Thanks)

RodalErmakov avatar Jun 26 '16 04:06 RodalErmakov

The same issue on "add new event" page in the events extension. screen

player0k avatar Jun 26 '16 17:06 player0k

Yes, the same problem here

dylan-ngo11 avatar Jun 27 '16 01:06 dylan-ngo11

How to fix the error on frontend

  • Create a new application in Google Account and get the API key.
  • Overwrite map shortcode static.php and add the key query parameter in script url. Replace this line with
'https://maps.googleapis.com/maps/api/js?'. http_build_query(array(
    'v' => '3.23',
    'libraries' => 'places',
    'language' => $language,
    'key' => 'YOUR_API_KEY',
)),

ghost avatar Jun 27 '16 12:06 ghost

I think need to rewrite option-type map: add new input for API Key, and after saving page value show map and other inputs, or add some parameter for this option-type

player0k avatar Jun 27 '16 14:06 player0k

https://github.com/ThemeFuse/Unyson/pull/1683

ghost avatar Jun 27 '16 14:06 ghost

This issue fixed frontend error but backend still showing this error. still a popup open in backend

Ataurr avatar Jun 27 '16 15:06 Ataurr

~~How to fix the error in backend~~ OUTDATED. USE THIS SOLUTION

  1. Create a new application in Google Account and get the API key.
  2. Add in {theme}/functions.php or your theme hooks.php file
/**
 * Dequeue default google maps option type script wich doesn't have API key
 * and enqueue one with an API key
 */
function _action_theme_replace_gmaps_script() {
    $handle = 'google-maps-api-v3';

    if (!wp_script_is($handle)) {
        return;
    }

    // https://github.com/ThemeFuse/Unyson/blob/v2.5.6/framework/includes/option-types/map/class-fw-option-type-map.php#L32-L38
    {
        wp_dequeue_script($handle);
        wp_deregister_script($handle);
    }

    wp_enqueue_script(
        $handle,
        'https://maps.googleapis.com/maps/api/js?'. http_build_query(array(
            'v' => '3.15',
            'libraries' => 'places',
            'language' => substr( get_locale(), 0, 2 ),
            'key' => 'YOUR_KEY'
        )),
        array(),
        fw()->manifest->get_version(),
        true
    );
}

function _action_theme_fw_init() {
    // https://github.com/ThemeFuse/Unyson-PageBuilder-Extension/commit/a780e1789e6ff454e3382ac71dd98c78b7844037
    if (version_compare(fw_ext('page-builder')->manifest->get_version(), '1.5.6', '>=')) {
        add_action('admin_enqueue_scripts', '_action_theme_replace_gmaps_script', 20);
    } else {
        add_action('admin_print_scripts', '_action_theme_replace_gmaps_script', 20);
    }
}

add_action('fw_init', '_action_theme_fw_init');

ghost avatar Jun 27 '16 17:06 ghost

Important! The above solutions (1 and 2) are temporary fixes, we are working on a fix that will be included in the next Unyson release.

ghost avatar Jun 27 '16 17:06 ghost

Thank @moldcraft

giathinh910 avatar Jun 28 '16 07:06 giathinh910

Thanks @moldcraft 👍 Do you have an estimate of when the next release will be so I can inform my customers please?

martinburdon avatar Jun 28 '16 19:06 martinburdon

@martinburdon https://github.com/ThemeFuse/Unyson-Extensions-Approval !

ghost avatar Jun 28 '16 20:06 ghost