AddressPRO

Docs Fields Address

#Field Render

Enter or search an address with an autocomplete feature, using the Google Places API. This field is similar to the ACF Google Map “Search” field, but with more customizable behavior.

Field Group
Search
US only

#Field Settings

Setting nameDescription
PlaceholderAppears within the input
Allow CountriesLimit the search to specific countries
Search TypeChoose the allowed search type: None, Geocode (non-business), Address, Regions, Cities or Business
Allow GeolocationAllow the user to find their current location
Allow Custom AddressAllow the user to enter an address not found in the Google Places API
PrependAppears before the input
AppendAppears after the input
API Key
The Google API Key
Individual Sub FieldsChoose which address component should be also saved as an individual sub field. For example: {my_field}_street_name

#Field Value

$address = get_field('address');

/**
 * array(
 *     'address'       => 'East Houston St/2 Ave, New York, NY, USA',
 *     'lat'           => 40.72397329999999,
 *     'lng'           => -73.99146499999999,
 *     'place_id'      => 'ChIJ5dnaVoRZwokRy1Cp3xQfuN0',
 *     'name'          => 'East Houston Street & 2 Avenue',
 *     'city'          => 'New York',
 *     'state'         => 'New York',
 *     'state_short'   => 'NY',
 *     'post_code'     => '10003',
 *     'country'       => 'United States',
 *     'country_short' => 'US',
 * )
 */

#Javascript Hooks

#Autocomplete Arguments

List of arguments passed to the Autocomplete library. See Google Places Autocomplete documentation.

/**
 * acfe/fields/address/args
 * 
 * @object  args   The autocomplete args
 * @object  field  ACF Field instance
 */
filter('acfe/fields/address/args',                         args, field);
filter('acfe/fields/address/args/name=my_address',         args, field);
filter('acfe/fields/address/args/key=field_608abfa17fa7f', args, field);
acf.addFilter('acfe/fields/address/args/name=my_address', function(args, field){
    
    args.types = ['hospital', 'pharmacy', 'bakery', 'country'];
    
    return args;

});

#Autocomplete Init

Triggered when the Google Places Autocomplete is initialized.

/**
 * acfe/fields/address/init
 * 
 * @object  args   The autocomplete instance
 * @object  field  ACF Field instance
 */
action('acfe/fields/address/init',                         autocomplete, field);
action('acfe/fields/address/init/name=my_address',         autocomplete, field);
action('acfe/fields/address/init/key=field_608abfa17fa7f', autocomplete, field);
acf.addAction('acfe/fields/address/init/name=my_address', function(autocomplete, field){
    
    autocomplete.setComponentRestrictions({
        country: ["us", "pr", "vi", "gu", "mp"],
    });

});