Odd: Google Maps blocked when maps integration disabled.
-
Hi,
I’m trying to get the consent tool working for an ACF/gmaps-API-based google maps integration. The basic structure thereof is given here:
https://www.advancedcustomfields.com/resources/google-map/Basically, I’m currently enqueueing in functions.php the google maps.js from Google, a local gmaps helper file (js) and a stylesheet.
I’ve tried the standard Complianz gmaps integration, and while it recognizes the target element for the placeholder, it doesn’t actually show the map upon consent. So I decided to switch the standard google maps integration off and do the following.
In functions.php –
// integrate COMPLIANZ Consent Manager for gmap integration. if ( function_exists( 'cmplz_has_consent' ) ) { if ( cmplz_has_consent( 'marketing' ) ) { wp_enqueue_script( 'google-maps', 'https://maps.googleapis.com/maps/api/js?key=...', array(), '1.0', true ); // acf_maps.js. wp_enqueue_script( 'acf_gmaps-js', get_template_directory_uri() . '/js/acf_gmaps.js', array(), $ver, true ); wp_enqueue_style( 'acf_gmaps-style', get_template_directory_uri() . '/js/acf_gmaps.css', array(), $ver ); } }
In addition, I’m wrapping the map element in a consent shortcode
echo do_shortcode( '[cmplz-consent-area cache_redirect="true" category="marketing"] ... MAPS ELEMENT... [/cmplz-consent-area]
Clicking on the rendered consent short codes works fine for the change in the consent settings. The scripts are also then properly loaded during the automated reload of the page, as a look in the dev tools shows.
However, the ACF/gmaps js-script will throw a “google is not defined” error, and the map will not load. I assume(d) this is due to a load sequencing problem of the two scripts.
But here’s the weird thing: When I enabled safe mode for Complianz to disable all integrations – while, again, no integrations were actually active – the above setup worked just fine. The page with the map was loaded or not loaded upon every change of the consent setting and it was always correctly displayed.
Upon disabling of the “safe mode” the “google is not defined” error reappeared and the map would no longer display.
Is there a simple solution here? Or will it be necessary to write a complete integration for this setup that would hopefully then solve the problem?
Thanks for any help!
The page I need help with: [log in to see the link]
- The topic ‘Odd: Google Maps blocked when maps integration disabled.’ is closed to new replies.