To use the control you will need a getAddress() API key. There is a free trial and the paid subscription are very reasonably priced.
Download and import the latest release
Once the solution has been imported you should have an example form on the contact entity with the address lookup configured enabled.
-
Configure the properties. Enter your getAddress() API key.
-
Adding the form script.
If you wish to integrate with custom address fields you will need to add the following to the On Load event hander (and replace the correct field names):
window.parent.addEventListener("onReceiveAddress", (ev: CustomEvent<EventData>) => {
if(ev.detail) {
if(ev.detail.Attribute === "[custom_postcode_field]"){
const address = ev.detail.Address;
formContext.getAttribute("[custom_address1_line1_field]").setValue(address.line_1);
formContext.getAttribute("[custom_address1_line2_field]").setValue(address.line_2);
formContext.getAttribute("[custom_address1_line3_field]").setValue(address.line_3);
formContext.getAttribute("[custom_address1_city]_field").setValue(address.town_or_city);
formContext.getAttribute("[custom_address1_county_field]").setValue(address.county);
formContext.getAttribute("[custom_address1_country_field]").setValue(address.country);
}
}
});