Sign up to Our

NEWSLETTER


 
Knowledgebase
Developers -- Google map zoom in and zoom out issue in third party themes
Posted by Nancy S. on 29 December 2016 07:37 AM

WPL loads Google map library itself. If a third party theme also loads Google map library it will cause a conflict between WPL and the theme. The issue will appear on the Google map in a way that if you zoom in or zoom out your map does not load. Also a JS issue will appear on console:

"You have included the Google Maps API multiple times on this page. This may cause unexpected errors."

 

For preventing this issue you need to disable Google map library that is loaded via the theme somehow. Bridge theme has an option for this purpose. You need to go to Qode options -> Contact page and set "Enable google map" on "No".

Disabling google map on Bridge theme

 

For other themes, First, you should search for an option in the theme backend to disable it. If there is no option, You need to remove it in another way. First, you should find where the google map library is loaded. For this purpose run the following code in your functions.php:

function wp_inspect_scripts() {
      global $wp_scripts;
      foreach( $wp_scripts->queue as $handle ) :
          echo $handle;
      endforeach;
}
add_action( 'wp_print_scripts', 'wp_inspect_scripts' );

All the handles will be printed. Then you need to find the google map handle library and deregister and dequeue in the child theme functions.php:

function wpjs_dequeue_script()
{
     wp_deregister_script('google-maps-api');
     wp_dequeue_script('google-maps-api');
}
add_action( 'wp_print_scripts', 'wpjs_dequeue_script' );

* Consider Google map library handle is "google-maps-api"

 

 

 


Comments (0)