Finds the location of a free-text address element, and the closest stores or other points of interest to that location.
The location is returned as an array of
DistancesFromPoint objects, each
representing the location of one possible alternative location.
The list of stores to find the nearest stores from must already be set up using the Find My Nearest
data list editor. The name of the data list to use should be supplied as the dataset
parameter.
By default, the three closest stores will be included in the result. This can be modified by supplying an Option
with a name of MaxMatches and a value of the number of stores you want to retrieve.
Language:
<!-- 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="http://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,
null,
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>
// NOTE: A reference to the web service must be added in Visual Studio with the URL
// http://webservices.data-8.co.uk/Location.asmx
private void FindMyNearest(LocationLicence licence, string point, string dataset)
{
// Invoke the web service method.
Location proxy = new Location();
FindMyNearestOutput results = proxy.FindMyNearest("username", "password", licence, point, dataset, null);
// Check that the call succeeded, and show the error message if there was a problem.
if ((results.Status.Success == false))
{
MessageBox.Show(("Error: " + results.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.
}
}
'NOTE: A reference to the web service must be added in Visual Studio with the URL
'http://webservices.data-8.co.uk/Location.asmx
Private Sub FindMyNearest(ByVal licence As LocationLicence, ByVal point As String, ByVal dataset As String)
'Invoke the web service method.
Dim proxy As Location = New Location()
Dim results As FindMyNearestOutput = proxy.FindMyNearest("username", "password", licence, point, dataset, Nothing)
'Check that the call succeeded, and show the error message if there was a problem.
If (results.Status.Success Is false) Then
MessageBox.Show(("Error: " + results.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.
End If
End Sub
Public Sub FindMyNearest(licence As String, postcode As String, dataset As String)
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "http://webservices.data-8.co.uk/recordset.ashx?service=Location&method=FindMyNearestSimple" &
"&username=your-username" &
"&password=your-password" &
"&licence=" & licence &
"&postcode=" & postcode &
"&dataset=" & dataset
If rs.MoveFirst Then
If rs.Fields(0).Name = "Success" And rs.Fields(0).Value = false Then
MsgBox "Error: " & rs.Fields(1)
Else
'TODO: Process method results here.
'Each result is available in a different row in the recordset.
'Results can be extracted from the following fields:
'Position_Description
'Position_StdDev
'Position_Easting
'Position_Northing
'Position_GridReference
'Position_Longitude
'Position_Latitude
'Position_CountyCode
'Position_County
'Position_DistrictCode
'Position_District
'Position_WardCode
'Position_Ward
End If
End If
End Sub
// NOTE: The php_soap.dll extension must be enabled in the php.ini file.
function FindMyNearest($licence, $point, $dataset)
{
$params = array(
"username" => "your-username",
"password" => "your-password",
"licence" => $licence,
"point" => $point,
"dataset" => $dataset,
"options" => $options
);
$client = new SoapClient("http://webservices.data-8.co.uk/Location.asmx?WSDL");
$result = $client->FindMyNearest($params);
if ($result->FindMyNearestResult->Status->Success == 0)
{
echo "Error: " . $result->FindMyNearestResult->Status->ErrorMessage;
}
else
{
// TODO: Process method results here.
// Results can be extracted from the following fields:
// $result->FindMyNearestResult->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.
// NOTE: This field contains an array of items, but if it contains only one item,
// PHP may not recognise it as an array. To always extract the result of this
// field as an array, we recommend you always access it using the
// getArrayFromResponse method described at
// http://www.php.net/soap_soapclient_soapcall#75797, e.g.
// foreach (getArrayFromResponse($result->FindMyNearestResult->Distances) as $item)
// {
// ...
// }
}
}