Skip to main content

JavaScript reference

AddressFinder.Widget class

This widget adds address verification to a simple form field.

More information about how to configure these options and changing the visual styles can be found on the advanced options page. The code examples page demonstrates many of these configuration options.

Constructor

ConstructorParameterDescription
AddressFinder.Widget()input:Element, api_key:String, country_code:String, options?:ObjectAttaches a new widget to the specified input element.

Methods

MethodParameterReturn valueDescription
on()event_name:String, callback:FunctionAddressFinder.WidgetSubscribes to a specified event.
trigger()event_name:String, argumentsAddressFinder.WidgetManually fires a specified event.
setOption()option_name:String, value:*AddressFinder.WidgetSets an option after the widget has been initialised.
setCountry()country_code:StringAddressFinder.WidgetSets a country after the widget has been initialised.
getOption()option_name:StringAddressFinder.WidgetGets the current value of the specified option.
addService()name:String, search_function:FunctionAddressFinder.ServiceFunction to add an additional third-party search.
disable()-AddressFinder.WidgetDisables the Addressfinder widget. The autocomplete function will stop operating until it is re-enabled.
enable()-AddressFinder.WidgetRe-enables a disabled Addressfinder widget.

Options

KeyTypeDescriptionDefault
address_paramsObjectAdditional parameters to filter the address results.{gnaf: "1"}
address_metadata_paramsObjectAdditional parameters to adjust the values returned with address metadata.nil
base_urlStringThe base URL endpoint for API calls and CSS resources.https://api.addressfinder.io
canonicalBooleanForce the selection of the canonical address when an aliased address is selected.true
containerObjectThe element that wraps in input field that AddressFinder will use. This is useful when embedding the widget within a scrolling panel.document.body
empty_classStringCSS class name to be applied to the li element containing the empty_content message.af_empty
empty_contentStringMessage to display to users when there are no found addresses or locations.No addresses were found. This could be a new address, or you may need to check the spelling.
footer_classStringCSS class name to be applied to the li element containing the footer.af_footer
hover_classStringCSS class name to be applied to the li element of a highlighted result.af_hover
ignore_returnsBooleanIgnore the use of the enter key when no list item is selected.true
item_classStringCSS class name to be applied to the li element of a result.af_item
list_classStringCSS class name to be applied to the ul element containing the results.af_list
location_paramsObjectAdditional parameters to filter the location results.{}
manual_styleBooleanIf true, the widget will not embed the default stylesheet, allowing a custom stylesheet to be used. (Can only be set when widget is constructed).false
max_resultsIntegerMaximum number of results to display.10
positionStringUse a different positioning value for the list_class element. When embedding AddressFinder within a fixed position element, using a matching fixed position value will ensure the popup list appears below the input element.'absolute'
show_addressesBooleanSet to false to hide address results.true
show_locationsBooleanSet to true to return location (Street, suburb, city) results.false

Events

EventsCallback argumentsDescription
"result:select"selectedAddress:String, metadata:ObjectFired when any result is selected. The metadata value returned depends on the type of address selected and country.
"address:select"selectedAddress:String, metadata:ObjectJust like "result:select", but only fired when an address is selected.
"address:select:pre"selectedAddress:String, metadata:ObjectFired immediately when an address is selected, before an info request for extended data is made.
"location:select"selectedLocation:String, metadata:ObjectJust like "result:select", but only fired when a location is selected.
"location:select:pre"selectedLocation:String, metadata:ObjectFired immediately when an location is selected, before an info request for extended data is made.
"results:update"-Fired when all services have updated their results.
"results:empty"-Fired when there are no results to display.

AddressFinder.Service class

Constructor

AddressFinder.Service is returned from the AddressFinder.Widget#addService method.

Method

MethodParameterReturn valueDescription
on()event_name:String, callback:FunctionAddressFinder.ServiceSubscribes an a specified event.
trigger()event_name:String, arguments...AddressFinder.ServiceManually fires a specified event.
setOption()option_name:String, value:*AddressFinder.ServiceSets an option after the widget has been initialised.
getOption()option_name:StringAddressFinder.ServiceGets the current value of the specified option.

Options

KeyTypeDescriptionDefault
rendererFunctionAllows a function to be defined to format how the result will be displayed. The function will be passed two arguments, the value and the data, and must return a string.-

Events

EventsCallback argumentsDescription
"result:select"selectedAddress:String, metadata:ObjectFired when a result from this service is selected.