Map shortcode stopped working
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
a screenshot of Alert from Contacts page

It works on my side

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...
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
i think so...
@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.
https://developers.google.com/maps/documentation/javascript/usage
Same here. Also a popup displayed

Hi)
Please help.
I have the same problem.
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)
The same issue on "add new event" page in the events extension.

Yes, the same problem here
How to fix the error on frontend
- Create a new application in Google Account and get the API key.
- Overwrite map shortcode
static.phpand add thekeyquery 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',
)),
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
https://github.com/ThemeFuse/Unyson/pull/1683
This issue fixed frontend error but backend still showing this error. still a popup open in backend
~~How to fix the error in backend~~ OUTDATED. USE THIS SOLUTION
- Create a new application in Google Account and get the API key.
- Add in
{theme}/functions.phpor your themehooks.phpfile
/**
* 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');
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.
Thank @moldcraft
Thanks @moldcraft 👍 Do you have an estimate of when the next release will be so I can inform my customers please?
@martinburdon https://github.com/ThemeFuse/Unyson-Extensions-Approval !