![]() ![]() 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) look for a function which is hooked on wpenqueuescripts and wpenqueuescript() to enqueue Google Maps. 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. First of all enqueue the Google Maps API js in the right way. Looks like the behaviour's changed in the latest version of WordPress - the above doesn't work (but I'll leave it for people on legacy versions).Sorry if I was unclear, i’ll try to explain it with errors. '&sensor=false' įor what it's worth, our (working) code is: wp_register_script('googlemaps', ''. First of all enqueue the Google Maps API js in the right way. However, I want my code to run the query that produces the GeoJSON data, and I know how to do that in php. I'm using Xampp to load Apache and view files on my browser. I suspect your problem is that it's being double-encoded, as you already have &. html the map shows up just fine, and it shows the data I want to see (a Linestring). I've got something similar in our code, and it's working fine (even encoded as &). ![]() I could of course just get the function to echo the HTML as a script tag, but I'd rather use the wp_enqueue_script system if possible. The Overflow Blog How do we get a tech team to make a big technical change A conversation with the folks. ![]() Detecting request type in PHP (GET, POST, PUT or DELETE) 1116. It is definitely not fine from Google's point of view. wp-enqueue-script google-maps or ask your own question. Loading Google Maps API with wpenqueuescript. I saw a bug of this kind mentioned in the WordPress trac system: but it was dismissed as invalid, and the admin responding to the request showed somehow that the "&" approach was fine. When I type it directly into browser address bar with "&sensor=false" at the end, it loads fine. This actually makes the Google server reject the request. WordPress is escaping the "&" to "&". Wp_enqueue_script('google-maps', $gmaps_url, NULL, NULL) Ive created an option tab with Advanced Custom fields where you can paste your Google Maps API key, so I dont have to put the API key in the code over and over again when starting a new project. You can rate examples to help us improve the quality of examples. $key = get_option('google_maps_api_key') PHP etpbenqueuegooglemapsscript - 3 examples found.These are the top rated real world PHP examples of etpbenqueuegooglemapsscript extracted from open source projects. Commonly the maps will be embedded within a wordpress post that has images that are styled. 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. The actual API key is configured in an options page I am creating a maps plugin for Wordpress that uses Google Maps JS API V3. Super Store Finder is a multi-language fully featured store locator PHP Application & WordPress Plugin integrated with Google Maps API v3 that allows customers to locate your stores easily. Howdy, I've got a site using events calendar pro v. I'm trying to load the Google Maps API using the following syntax: add_action('admin_enqueue_scripts', 'load_google_maps') ![]()
0 Comments
Leave a Reply. |