Settings

Edited

Introduction

Once the Autoaddress control is initialized, you can pass in several settings to customize your experience.

There are two settings which are the minimum requirements to be used in your control these are elementId and your authentication method which can be either apiKey or token.

Setup

The below code snippets demonstrates how to initialize the Autoaddress control with the two different authentication approaches.

In this code for the apiKey approach:

Autoaddress is an object representing the Autoaddress plugin, and you initialize it with configuration options.

elementId  specifies the ID of the HTML element where the Autoaddress plugin will be rendered.

apiKey should be replaced with your actual API key from the Account Center.

<script type="text/javascript">  
var aa = Autoaddress({
  apiKey: "YOUR_KEY",
  elementId: "aa-control", 
});
</script>

or

Similarly for initializing the control with the token approach you simply replace the apiKey property with the token property.  You should never add both properties. To retrieve a token, please see our createToken API documentation. 

<script type="text/javascript">  
var aa = Autoaddress({
  token: "YOUR_TOKEN",
  elementId: "aa-control", 
});
</script>

Setting options

Below you will find several configuration settings that are currently available for use on the Javascript control.

<script type="text/javascript">  
var aa = Autoaddress({
  apiKey: "YOUR_KEY",
  elementId: "aa-control", 
  // Sample usage of setting additional settings on the control
  // Set language 
  language: "en",
  // Set country bias
  country: "IE",
  // Turn off form validation (Only used in AutoaddressForm integration type)
  validateOnChange: false,
  // Change integration type - default is "AutoaddressForm"
  integrationType: "CustomerFormInline",
  // Add callback to capture address result
  onAddressResult: function (result) {
     // Parse address from result and populate your own form.
     // Result will you give you access to the full Lookup API response.
  }
});
</script>

Note: * indicates that this is Required

Setting

Description

Type

Default

elementId *

ID of the html element to attach the Autoaddress control to. Ensure this already exists on the page.  I.e "aa-control"

Note: If your integrationType is "CustomerFormInline" then the HTML element you are selecting with elementId must be an <input > type element.

string

None

apiKey 

API key for accessing the Autoaddress service.  This can be found on the Account center. 

string

None

token

An alternative approach to authentication is to use a token generated through the "createToken" API. In this case you can pass token directly to the control as a setting and skip setting apiKey.

string

None

integrationType

Change the layout of the form to suit your needs.  More details for each integration type can be found here.  

Select from

  1.  “AutoaddressForm”

  2. “Combo”

  3. “CustomerFormInline”

string

"AutoaddressForm"

elementSelector

Identify element by means other than ID such as class. E.G elementSelector: ".mydiv". Only required if elementId is not provided.
 
 I.e ".myContainer"

string

None

customerFieldId

ID of div encapsulating existing address form. Used for hiding and showing the form.

string

None

customerFieldSelector

Identify the customerField by means other than ID such as class. E.G customerFieldSelector: ".myForm"

string

None

validateOnChange

Default is true. Use this option to run form validation on form change events i.e. onBlur.

boolean

true

theme

Configure the styling for the js control. 

string

"material-theme"

language

Set language to be used for the plugin. This will control the language of labels/text used within the Autoaddress control and configure API results if different languages are available.

string

“en”

country

Set a country value if you want to bias address search towards a particular country.

string

“IE”

latitude

Allows you to bias address search results to given coordinates.

i.e. 40.7128

decimal

None

longitude

Allows you to bias address search results to given coordinates.

i.e -74.0060

decimal

None

limit

Set the max number of options to return from Autocomplete and Search requests. Minimum value = 3, Maximum value = 30.

int

8