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!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.