Javascript Library v2.1.0
Javascript library to to use Loqate Harmony solutions from client side
Last updated
Javascript library to to use Loqate Harmony solutions from client side
Last updated
Harmony API Account.
We strongly recommend when implementing this method.
Looking to quickly add Harmony to your project? Harmony JS library can be deployed on a web page, allowing users to connect directly to the Harmony API services without any server-side processing requirements. Its recommended to .
Use our content delivery by copying and pasting into your html
Using a package manager or need to download the source files? Download the files located in content delivery.
Before making service requests, the client must be initialised. This is done by invoking the init
method on the global Harmony
object:
This method must be called before any other methods are invoked on the Harmony
object.
During initialization, the client environment is set to Production and the protocol is set to CORS. To use the Production environment or the JSONP protocol, the useEnv
and useProtocol
methods can be used.
Once the client has been initialized, any methods available to the supplied user can be invoked. These methods are invoked using the global Harmony
object.
The following example invokes the find
method with the single-line address '1 abc street' in Canada. The callback method then output the addresses in a textarea with the id 'output':
Only use FeatureOptions when you want to change the system defaults.
The following example configures feature options for address lookup service methods.
The client library acts as an extension of Javascript Library for Address Find (Autocomplete).
Please refer to the Code snippet section to copy and paste to your web page.
Adds a new field specifying the field name (e.g. Harmony.POSTCODE
, Harmony.LOCALITY
, etc) or the attribute name (e.g. "attributes.Line1"
, "attributes.Latitude"
, etc), and the input element.
2.0.0
Single-line address lookup on the supplied input
element.
2.0.0
Adds a new field specifying the field name (e.g. Harmony.POSTCODE
, Harmony.LOCALITY
, etc) or the attribute name (e.g. "attributes.Line1"
, "attributes.Latitude"
, etc), and the input element.
Type: String
The name of the field (e.g. Harmony.POSTCODE
) or attribute (e.g. "attributes.Line1"
) to be added.
Type: Object
The input
element to be assigned to the field (e.g. document.getElementById("postcodeField"))
.
Type: Integer
The optional index if there are multiple sets of lookups on the same page (e.g. one for residential addresses and the other one for postal addresses). Currently only available for addressLookup
.
The following example assigns the Harmony.LOCALITY
field to the input element with localityField
ID and the "attributes.Latitude"
attribute to the input element with latitudeField
ID:
Type: Object
The input
address element to create the lookup for (e.g. document.getElementById("address")
).
Type: String or Object
The Country used for the lookup. It can be String (e.g. Harmony.AUSTRALIA
for Australia) or Object in input
or select
Country element (e.g. document.getElementById("country")
).
Type: String or Object
The Source of Truth to override the default Australia and New Zealand SOTs. It is optional. It can be String (e.g. Harmony.AUPAF
for Australia) or Object in input
or select
Source of Truth element (e.g. document.getElementById("sourceOfTruth")
).
Type: Object
Optional parameter to be passed into the auto-complete component (e.g. getIntlGeocode
true/false to enable international geocode call for the selected address, default is false. And callback functions e.g. onRetrieve
and onIntlGeocode
in below sample).
Type: Integer
Optional index to indicate which set of fields to populate if there are multiple lookups on the same page.
The following example creates a single-line address lookup (use AUPAF for Australian addresses) on the input element with ID singleLineAddress
and country
and customized opts
:
The following is an example of how the generated code looks. Please note, the actual user and credential will be different for different customers.
Creates single-line address lookup with on the supplied input
and country
elements. It returns the response from service and the callback is available via onSelect
option.
For service, the response is available via ui.onRetrieveItem
and the callback is available via onRetrieve
option. For internationalGeocode service, if getIntlGeocode
options is enabled, the response is available via ui.onIntlGeocodeItem
and the callback is available via onIntlGeocode
option.
Loqate Harmony API provides a self-service console where a customer can quickly generate a ready to use code snippet. You can find more information .