AddressFinder.Widget class
Constructor
Constructor | Parameters | Description |
---|---|---|
AddressFinder.Widget() |
input:Element , api_key:String , country_code:String , options?:Object |
Attaches a new widget to the specified input element. |
Methods
Method | Parameters | Return Value | Description |
---|---|---|---|
on() |
event_name:String , callback:Function |
AddressFinder.Widget | Subscribes to a specified event. |
trigger() |
event_name:String , arguments …> |
AddressFinder.Widget | Manually fires a specified event. |
setOption() |
option_name:String , value:* |
AddressFinder.Widget | Sets an option after the widget has been initialised. |
setCountry() |
country_code:String |
AddressFinder.Widget | Sets a country after the widget has been initialised. |
getOption() |
option_name:String |
AddressFinder.Widget | Gets the current value of the specified option. |
addService() |
name:String , search_function:Function |
AddressFinder.Service | Function to add an additional third-party search. |
disable() |
AddressFinder.Widget | Disables the AddressFinder widget. The autocomplete function will stop operating until it is re-enabled. | |
enable() |
AddressFinder.Widget | Re-enables a disabled AddressFinder widget. |
Options
Option | Type | Default | Description |
---|---|---|---|
address_params |
Object | {strict: "2"} |
Additional parameters to filter the address results. NZ Address params, AU Address params and International Address params. The Code Examples page has some good examples. |
address_metadata_params |
Object | nil |
Additional parameters to adjust the values returned with address metadata. NZ Address Metadata params, AU Address Metadata params, International Address Metadata params. |
base_url |
String | https://api.addressfinder.io |
The base URL endpoint for API calls and CSS resources. |
canonical |
Boolean | true |
Force the selection of the canonical address when an aliased address is selected. |
container |
Object | document.body |
The element that wraps in input field that AddressFinder will use. This is useful when embedding the widget within a scrolling panel. The Code Demos page has some good examples. |
empty_class |
String | 'af_empty' |
CSS class name to be applied to the li element containing the empty_content message. |
empty_content |
String | No addresses were found. This could be a new address, or you may need to check the spelling. Learn more |
Message to display to users when there are no found addresses or locations. |
footer_class |
String | 'af_footer' |
CSS class name to be applied to the li element containing the footer. |
hover_class |
String | 'af_hover' |
CSS class name to be applied to the li element of a highlighted result. |
ignore_returns |
Boolean | true |
Ignore the use of the enter key when no list item is selected. |
item_class |
String | 'af_item' |
CSS class name to be applied to the li element of a result. |
list_class |
String | 'af_list' |
CSS class name to be applied to the ul element containing the results. |
manual_style |
Boolean | false |
If true, the widget will not embed the default stylesheet, allowing a custom stylesheet to be used. (Can only be set when widget is constructed). |
max_results |
Integer | 10 |
Maximum number of results to display. |
position |
String | 'absolute' |
Use 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. |
show_addresses |
Boolean | true |
Set to false to hide address results. |
Events
Event | Callback Arguments | Description |
---|---|---|
"result:select" |
selectedAddress:String , metadata:Object |
Fired when any result is selected. The metadata value returned depends on the type of address selected, which depends on the search criteria supplied. The metadata could be either Australian Address metadata, Australian Location metadata, New Zealand Address metadata, New Zealand Location metadata or New Zealand Point of Interest metadata |
"address:select" |
selectedAddress:String , metadata:Object |
Just like "result:select" , but only fired when an address is selected. The metadata could be either
Australian Address metadata or
New Zealand Address metadata
|
"address:select:pre" |
selectedAddress:String , metadata:Object |
Fired immediately when an address 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
Constuctor
AddressFinder.Service is returned from the AddressFinder.Widget#addService method.
Methods
Method | Parameters | Return Value | Description |
---|---|---|---|
on() |
event_name:String , callback:Function |
AddressFinder.Service | Subscribes an a specified event. |
trigger() |
event_name:String , arguments … |
AddressFinder.Service | Manually fires a specified event. |
setOption() |
option_name:String , value:* |
AddressFinder.Service | Sets an option after the widget has been initialised. |
getOption() |
option_name:String |
AddressFinder.Service | Gets the current value of the specified option. |
Options
Option | Type | Default | Description |
---|---|---|---|
renderer |
Function | Allows 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
Event | Callback Arguments | Description |
---|---|---|
"result:select" |
selectedAddress:String , metadata:Object |
Fired when a result from this service is selected. |
Address Params
Property | Type | Description |
---|---|---|
max |
Integer | The maximum number of results to return. A number between 1 and 15. The default is 10 results. |
Address Metadata Params
Property | Type | Description | Default value |
---|---|---|---|
gps |
String | Request GPS coordinates for latitude and longitude be returned when available |
0 |
Yes |
GPS coordinates wil be included in the response | 1 | |
No |
0 |
Address metadata
Property | Type | Description | Example |
---|---|---|---|
id
|
String | Unique address identifier obtained from the Address Autocomplete | 2fjZ2wvSHufT0ruefqNH13rYtBKS6ZZukGxPowcuqmUB/s_nIJl_--trguceJRa_eztyLG--jl1iVIoZZZaQYvF/erphow== |
address
|
Group | Address information as supplied by our sources. Contains the following fields: | |
address_line_1 |
String |
First address line in the country specific format, usually includes unit number, street number, name, etc. Can be used on forms with multiple address fields. | 123 Edward St |
address_line_2 |
String |
Second address line in the country specific format, usually includes locality, neighbourhood, etc. Can be used on forms with multiple address fields. | Silver Berry |
address_line_combined |
String |
Country specific lines 1 and 2 combined into one. Can be used on forms with a single address field. | 123 Edward St, Silver Berry |
city |
String |
The city, town or locality name as assigned by our sources | Toronto |
city_line |
String |
The city in a format suitable for postal services | Toronto ON M5G |
postcode |
String |
Holds the country specific postcode | M5G |
state |
String |
Country specific state/region/district | ON |
country_name |
String |
Name of the country the address belongs to | Canada |
country_code |
String |
ISO 3166-1 alpha-2 code of the country | CA |
metadata
|
Group | Other metadata as supplied by our sources. Contains the following fields: | |
street |
String |
Holds the full name of the street as supplied by our sources | Edward St |
street_number |
String |
Holds the street number as supplied by our sources | 123 |
state_code |
String |
Holds the two letter code of the province | ON |
state_name |
String |
Holds the full name of the province | Ontario |
position
|
Group | Contains the GPS coordinates if requested via the gps param | |
latitude |
Float |
Latitude in the decimal degrees format | 42.993184 |
longitude |
Float |
Longitude in the decimal degrees format | -81.184534 |
success
|
Boolean | Indicates if the request was successful or not. | true |