[ 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.
- 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.
- 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);
}
});
NOTES
Full details of request and response object parameters are set out in the JSON API.