Now this works fine on the checkout page, however on other pages i’m getting errors as the script is not included there. Therefore I added in a check, to see if it is the checkout page ‘setup.php’ Since i only use the Google Maps script on the checkout page, I only want to enqueue it there. Then in webpack externals i have: google: 'google' In which i do import google from 'google' and the code that interacts with the api of course. I also have a routed JS file on the checkout page. Wp_enqueue_script('google-places', ''.get_option( 'bull-api-keys-maps-key'), false, null ,false) I’m using the Google Maps API on the WooCommerce checkout page to autocomplete the address fields.Ĭurrently I enqueue the Google Maps script in ‘setup.php’ on all pages. But in response to your concern about the place to put this code, it really doesn't matter where in the functions.php you put this code. Sorry if I was unclear, i’ll try to explain it with errors. You are using wpenqueuescripts() in the proper way, however you are enqueuing everything in the footer, and re queuing jQuery (which is not a good practice, you could use jquery-migrate instead). Find the part in the code where the Google Maps API is being called, and use condition below, if you’re not sure or familiar in coding, you can request our devs to do it, and we’ll quote you accordingly $url = '. We would recommend you to download the theme files to local machine, then, use Notepad++ and search for keyword maps.google usually it looks like code below wp_enqueue_script('google-maps', '///maps/api/js'.Ģ. Latest themes will have an option to disable Google Maps API calls moving forward (which most themes already have right now) because the plugin has a special call with parameters for the store locator.īut certain web owners will want to use the Google maps on the Contact Us page, thus disabling it will make the contact form not working, thus we propose a solution below.ġ. The most common solution for all major theme is to modify the theme code or have an option to disable it If it’s conflicting with your theme, at the moment there’s no choice because the plugin calls google maps api with special parameters where most theme do not.ģ. If you suspect that there are other plugins using Google Maps API, you can refer to this article to disable other plugins (using Plugin Organizer – Download here) on your Super Store Finder page.Ģ. If you’re facing this issue, recommended solution as below:ġ. * Google Maps API has been changed in Feb 2016 causing a lot of javascript error if multiple map APIs being called at once Make sure you only load the Google Maps API once which from Super Store Finder plugin which has calls to specific libraries and parameters. You have included the Google Maps API multiple times on this page. This may cause unexpected errors. I get an error: 'You have included the Google Maps API multiple times on this page. The site is also using google maps api to display a map in the footer on all pages. When this occurs, an error will be printed to the javascript console related to the Google Maps API. Howdy, I've got a site using events calendar pro v. If two or more plugins (or theme) load the Google Maps API, and the library is loaded twice, a javascript error will occur and the maps will stop working. Also thanks to the suggestion you posted last week for someone else regarding Divi and turning off Enqueue Google Maps Script is settings to get the Map Block working. I spent too much time experimenting with this. However, this should only be loaded once. Can I make a suggestion that the display of this message be changed as it is disconcerting and suggests that the maps will not work. Themes and plugins that want to use Google Maps functionality load the Google Maps API javascript.
0 Comments
Leave a Reply. |