acf/fields/google_map/api

Overview

This filter allows you to modify the URL parameters used to load Google Maps JS. Its primary use is to allow a Google API key to be set, however, may also be used to customize other_params used in the google.load function.

Changelog

  • Added in version 4.3.9 (ACF) and 5.3.10 (ACF PRO)

Parameters

  • $api (array) an array of all API info detailed below

$api

$api = array(
	
	/* (string) the map libraries to be loaded */
	'libraries'		=> 'places',
	
	/* (string) Google API key */
	'key'			=> '',
	
	/* (string) Google API client ID */
	'client'		=> ''
	
);

Usage

This example shows how to register a Google API key to be used when loading the Google Maps JS.

functions.php

function my_acf_google_map_api( $api ){
	
	$api['key'] = 'xxx';
	
	return $api;
	
}

add_filter('acf/fields/google_map/api', 'my_acf_google_map_api');

Related

Hi all. Server maintenance scheduled this Sunday 28th May. Learn more