I’m loading two scripts into my checkout page:
function wpb_adding_scripts() {
if ( function_exists( 'is_woocommerce' ) ) {
if ( is_woocommerce() && is_checkout() ) {
wp_register_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=[iprovidemykeyhere]&callback=initMap');
wp_register_script('location_tracker', get_stylesheet_directory_uri() . '/js/track_location.js', array('google-maps-api'));
wp_enqueue_script('google-maps-api');
wp_enqueue_script('location_tracker');
}
}
}
add_action( 'wp_enqueue_scripts', 'wpb_adding_scripts', 999 );
… but I get the following although I am correctly providing the key in the URL above:
Google Maps API warning: NoApiKeys
https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keysGoogle Maps API warning: SensorNotRequired
https://developers.google.com/maps/documentation/javascript/error-messages#sensor-not-required
Step 1: please go to your Google Console and enable
Google Maps JavaScript API
from overview tab, so go toCredentials
tab and make an API key for your project.Step 2: add below line to your html and change
yourKEYhere
by your api key.Step 3: use
gmaps.js
plugin.Good luck!