Home › Forums › Backend Issues (wp-admin) › Google Maps field needs setting to add API key › Reply To: Google Maps field needs setting to add API key
Hi guys.
Here is the working func. Just paste
YOUR_KEY = google maps API key
advanced-custom-fields-pro/assets/js/acf-input.min.js
/*
* is_ready
*
* This function will ensure google API is available and return a boolean for the current status
*
* @type function
* @date 19/11/2014
* @since 5.0.9
*
* @param n/a
* @return (boolean)
*/
is_ready: function(){
// reference
var self = this;
// ready
if( this.status == 'ready' ) {
return true;
}
// loading
if( this.status == 'loading' ) {
return false;
}
// no google
if( !acf.isset(window, 'google', 'load') ) {
// set status
self.status = 'loading';
// load API
$.getScript('https://www.google.com/jsapi', function(){
// load maps
google.load('maps', '3', { other_params: 'sensor=false&key=YOUR_KEY&libraries=places', callback: function(){
// set status
self.status = 'ready';
// initialize pending
self.initialize_pending();
}});
});
return false;
}
// no maps or places
if( !acf.isset(window, 'google', 'maps', 'places') ) {
// set status
self.status = 'loading';
// load maps
google.load('maps', '3', { other_params: 'sensor=false&key=YOUR_KEY&libraries=places', callback: function(){
// set status
self.status = 'ready';
// initialize pending
self.initialize_pending();
}});
return false;
}
// google must exist already
this.status = 'ready';
// return
return true;
},
initialize_pending: function(){
// reference
var self = this;
this.$pending.each(function(){
self.doFocus( $(this) ).initialize();
});
// reset
this.$pending = $();
},
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
ACF wouldn’t be so widely used in WordPress if it didn’t have some pretty amazing capabilities. In this article, we look at a few of the features we’ll discuss during “7 things you didn’t know you could do with ACF” at #WPEDecode later this month. https://t.co/5lnsTxp81j pic.twitter.com/Yf0ThPG1QG
— Advanced Custom Fields (@wp_acf) March 16, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.