Advanced Guide

This advanced guide provides further customisation options for AddressNow Capture for developers.

Prerequisite: You'll need to know how to access the source code for your website and have permission to change it.

Advanced Customisations

The AddressNow Capture – Getting Started guide will cover the majority of website installations needed when using the AddressNow service. However it is possible that in certain situations you may need to customise the way AddressNow works in some way to accommodate your processes or your site.

With this in mind, once you have followed the Getting Started Guide and need to make further customisations, the below options are available.

Loading AddressNow manually

Once added into the page via the JavaScript and CSS AddressNow will load at the point of page load. However it is possible that under certain circumstances you may need to manually trigger the load of AddressNow. This is useful if your fields load after AddressNow (and therefore AddressNow can’t detect your fields at the point it loads).

<script type="text/javascript">
    addressNow.load();
</script>

Adding this after your fields have loaded should ensure AddressNow detects your fields and functions correctly on the page. It also allows you to re-load AddressNow if the fields on your form are dynamically altered at any point.

To disable AddressNow

If you want to stop AddressNow from functioning after it has loaded on your page then the below code can be used.

<script type="text/javascript">
    addressNow.disable();
</script>

Removing the AddressNow bar

It is possible to suppress the bar that appears at the bottom of the AddressNow results when performing a search. This can be achieved by putting the below code on the page after AddressNow has been initialised.

<script type="text/javascript">
    addressNow.listen("options",
        function(options) {
            options.bar = options.bar || {};
            options.bar.visible = false;
        });
</script>

Max results/suggestions

By default AddressNow will limit the number of suggestions made during the search process to 7, and the number of results returned once a selection has been made by the user to 100. It is possible to increase these numbers to 50 and 300 respectively.

<script type="text/javascript">
    addressNow.listen("options",
        function(options) {
            options.search = {
                maxSuggestions: 7,
                maxResults: 100
            };
        });
</script>

On load event

It is possible you may want to run some code of your own at the point when AddressNow loads. This can be achieved by listening for the event.

<script type="text/javascript">
    addressNow.listen("load",
        function(control) {
            ///your code here
        });
    });
</script>

On populate event:

Like the on load event, it is also possible to fire some of your own code when AddressNow has populated an address back to your form. This can be achieved by listening for the populate event.

<script type="text/javascript">
    addressNow.listen("load",
        function(control) {
            control.listen("populate",
                function(address) {
                    ///your code here
                });
        });
</script>

Accessing the contents of the response from an address retrieve request

The contents of the response from an AddressNow request can be accessed and then manipulated if you need to use the various elements of the address. Insert the code below into your page and then modify to access the relevant part of the address object (for example, in the example below: “Postcode”).

<script type="text/javascript">
    addressNow.listen('load', function(control) {
        control.listen("populate", function (address) {
            document.getElementById("line1").value = address.Line1;
        });
    });
<script>