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

The API provides another simple way to geocode an address, based on user input. It's a two-step process.

  1. Use the Suggest service to retrieve suggested matches for whatever address text your end-user enters. The response includes the ID for the suggested match.
  2. Using the returned ID, use the Details service to retrieve the corresponding geocode object, including its centre point and more complete address information.
Sample request sequence
var service = new EMS.Service.Suggest();
var detailService = new EMS.Service.Details();

service.suggest("Melbourne", callback);
function callback(response, status){
  if(status == EMS.Status.OK) {
     var suggestions = response.suggestions;
     var firstId = suggestions[0].id;
     detailService.find(firstId, detailCallback);
  } else {  
     alert(response.message);
  }
});

function detailCallback(response, status) {
    if (status == EMS.Status.OK) {
        // Success! Use the geocode object
    } else  {
        alert(response.message);
    }
});

NEXT PAGE

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

 

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, see the JavaScript Command Reference and the following working examples:

  • Suggest
  • Details