0151 355 4555

FindMyNearest

Description

Finds the nearest entries (e.g. stores) from a pre-defined data set to an address. location of a postcode.

The postcode parameter can be set to either a full or partial postcode, or a free-text address.

The response will contain the details of the 3 nearest entries from the data set to the supplied address, ranked in order of distance.

The number of entries included in the response can be controlled by an Option with the name MaxMatches.

View all Geocoding (contact us for more information about this service) methods

Code Samples

<!-- Import the Integr8 Ajax API -->
<!-- NOTE: Get your own API key to use in the following script tag from: -->
<!-- http://www.data-8.co.uk/integr8/Admin/Ajax.aspx -->
<script src="https://webservices.data-8.co.uk/Javascript/Loader.ashx?key=your-api-key" type="text/javascript">
</script>

<script type="text/javascript">

function loadIntegr8() {
  // Load the Location Integr8 service
  data8.load('Location');
}

function FindMyNearest(licence, point, dataset) {
  /// <param name="licence">string. One of the following values: WebServer, WebClick, InternalUser, SmallUser, Lookup, InternalServer</param>
  /// <param name="point">string</param>
  /// <param name="dataset">string</param>
  var location = new data8.location();
  
  location.findmynearest(
    licence,
    point,
    dataset,
    [
      new data8.option('MaxMatches', '5')
    ],
    showFindMyNearestResult
  );
}

function showFindMyNearestResult(result) {
  // Check that the call succeeded, and show the error message if there was a problem.
  if (!result.Status.Success) {
    alert('Error: ' + result.Status.ErrorMessage);
  }
  else {
    // TODO: Process method results here.
    // Results can be extracted from the following fields:
    // result.Distances
    //   Contains a list of the possible points that could have been intended by the user, and a list of the closest points in the Find My Nearest data set to each one, with the closest point first.
  }
}

loadIntegr8();

</script>