[ Whereis® API Home ] [ Developers' Guide ] [ JS Services ]

The Address Validation service provides the capability to determine the accuracy of an address, to correct an erroneous address, and to report the types of adjustments that were required.

To validate an address, perform the following steps.

  1. Initialise the Validation service.
  2. Format the request.
  3. Submit the request, nominating a callback function.

If the request succeeds, the API returns a list of Validation objects (a Geocode object with an array of Adjustment Types).

    4. Process the response within the callback function.

A successful request returns a list of results. In some cases the list may be empty or may contain only one result at index[0]. Each response object will include adjustments and a geocode, which contains coordinates and the address for the location.

The following code snippet performs a validation and retrieves the first usable result.

 

//Initialise service
var service = new EMS.Service.Validation();

//Format request
var query = "55 Lonsdale Street, Melbourne";

//Submit request
service.validate(query, callback);

//Handle the response
function callback (response, status){

// Check the status of the result is non-error
    if (status == EMS.Status.OK) {

       // Success! check the results
       var items = response.results;
       if (items.length > 0) {
           var msg = items[0].toString();
           alert(msg);
       } else {
          // Found nothing
       }
    } else {
       // Error! Display the message.
       alert(response.message);
    }
};

NEXT PAGE

NOTES

Full details of request and response object parameters are set out in the JSON API.

There is also an appendix of Address Adjustment Types

Icon

The JSON API uses Australian English. The parameter documented as "centrePoint" must be retrieved through the JavaScript API as "centerPoint".

Icon

Remember that all points must be passed in and are returned in WGS84 format. For the EMS JavaScript API to centre on, or otherwise manipulate, a returned point, convert the coordinates to their EMS.LonLat equivalent.

Icon

For more information, refer to the JavaScript Command Reference and to the following working examples: