Back to Community

Troubleshooting Google Maps Block Errors in Kadence Blocks

Content

Users of the Gutenberg Blocks with AI by Kadence WP plugin often encounter a specific JavaScript error with the Google Maps block when the 'Use Javascript API' option is enabled. This guide explains the problem and outlines the most effective troubleshooting steps.

The Problem: 'kbInitMaps is not a function'

When the 'Use Javascript API' setting is activated, the Google Maps block may fail to render on the front end of a website, leaving a blank space. A check of the browser's developer console often reveals the error: Uncaught TypeError: kbInitMaps is not a function. This indicates a problem with the script loading and initialization process required by the Google Maps JavaScript API.

Why This Happens

The error typically occurs due to a conflict or interruption in the script execution chain. The 'Use Javascript API' option relies on a specific callback function (kbInitMaps) being available when the external Google Maps API script finishes loading. If this function is not defined at the precise moment the API is ready, the map initialization fails. Common causes for this breakdown include:

  • Caching: Aggressive caching mechanisms (server, plugin, browser, or CDN) may be serving an old version of the page's scripts that do not include the necessary function definitions.
  • Plugin or Theme Conflict: Another plugin or the active theme might be enqueuing scripts in a way that interferes with the load order or execution of the Kadence Blocks scripts.
  • Optimization Settings: Script optimization, concatenation, or lazy loading features in performance plugins can sometimes break the dependency and timing the Google Maps API requires.

How to Troubleshoot and Fix the Error

Follow these steps to resolve the 'kbInitMaps is not a function' error.

Step 1: Clear All Caches

This is the most common fix. You must clear every layer of cache on your site:

  • WordPress Cache: If you use a caching plugin like WP Rocket, W3 Total Cache, or WP Super Cache, clear its cache.
  • Server / CDN Cache: Clear any cache provided by your hosting provider (e.g., Varnish, Nginx) or your Content Delivery Network (e.g., Cloudflare). Consult your host's documentation for instructions.
  • Browser Cache: Perform a hard refresh (Ctrl + F5 on Windows, Cmd + Shift + R on Mac) or clear your browser's cached images and files.

After clearing all caches, revisit the page with the map to see if it loads correctly.

Step 2: Check for Conflicts

A plugin or theme conflict could be causing the issue. To test for this:

  1. Temporarily switch your theme to a default WordPress theme like Twenty Twenty-Two.
  2. Deactivate all plugins except for Kadence Blocks.

If the map works after these changes, you have a conflict. Reactivate your theme and plugins one by one, checking the map after each activation, to identify the culprit. Once identified, you can configure the conflicting software or seek an alternative.

Step 3: Review Optimization Plugins

If you use a performance optimization plugin, its settings might be the source of the problem. Try temporarily disabling features like:

  • JavaScript minification/concatenation
  • Lazy loading of scripts
  • Defer or delay JavaScript

If disabling one of these features fixes the map, you can often resolve the issue by adding an exclusion for the Kadence Maps script. Based on community reports, the script often uses a class name like kb-google-maps-container. Consult your optimization plugin's documentation on how to exclude specific scripts or elements from processing.

Step 4: Verify API Key and Configuration

While the original error points to a JavaScript issue, it's always good practice to ensure your Google Maps API key is valid, active, and has the correct permissions (typically the 'Maps JavaScript API' enabled). An invalid or misconfigured key can sometimes lead to unexpected behavior.

Conclusion

The 'kbInitMaps is not a function' error is almost always solvable by methodically working through caching and conflict scenarios. Starting with a full cache clearance is the recommended first step for most users. If the problem persists, systematically testing for conflicts with other plugins or themes will usually identify the root cause.