Finds the location of a free-text address element. The location is returned as an array of FuzzyPosition objects, each
representing the location of one possible alternative location.
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 Geocode(licence, name) {
/// <param name="licence">string. One of the following values: WebServer, WebClick, InternalUser, SmallUser, Lookup, InternalServer</param>
/// <param name="name">string</param>
var location = new data8.location();
location.geocode(
licence,
name,
null,
showGeocodeResult
);
}
function showGeocodeResult(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.Results
// Contains the positions of any locations that match the query.
// The position can be extracted from these values in any of three ways:
// 1. Using the Easting and Northing fields, measured in metres east and north
// of the point at 49° N, 2° W.
// 2. Using the GridReference field to get the standard Ordnance Survey grid reference.
// 3. Using the Latitude and Longitude fields to get the location according to
// the selected datum (defaults to WGS84)
// For areas larger than a single postcode, the StdDev field indicates the spread of
// addresses within the area.
}
}
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 Geocode(LocationLicence licence, string name)
{
// Invoke the web service method.
Location proxy = new Location();
GeocodeOutput results = proxy.Geocode("username", "password", licence, name, 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.Results
// Contains the positions of any locations that match the query.
// The position can be extracted from these values in any of three ways:
// 1. Using the Easting and Northing fields, measured in metres east and north
// of the point at 49° N, 2° W.
// 2. Using the GridReference field to get the standard Ordnance Survey grid reference.
// 3. Using the Latitude and Longitude fields to get the location according to
// the selected datum (defaults to WGS84)
// For areas larger than a single postcode, the StdDev field indicates the spread of
// addresses within the area.
}
}
'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 Geocode(ByVal licence As LocationLicence, ByVal name As String)
'Invoke the web service method.
Dim proxy As Location = New Location
Dim results As GeocodeOutput = proxy.Geocode("username", "password", licence, name, 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.Results
' Contains the positions of any locations that match the query.
' The position can be extracted from these values in any of three ways:
' 1. Using the Easting and Northing fields, measured in metres east and north
' of the point at 49° N, 2° W.
' 2. Using the GridReference field to get the standard Ordnance Survey grid reference.
' 3. Using the Latitude and Longitude fields to get the location according to
' the selected datum (defaults to WGS84)
' For areas larger than a single postcode, the StdDev field indicates the spread of
' addresses within the area.
End If
End Sub
Public Sub Geocode(licence As String, name 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=GeocodeSimple" &
"&username=your-username" &
"&password=your-password" &
"&licence=" & licence &
"&name=" & name
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:
'Description
'StdDev
'Easting
'Northing
'GridReference
'Longitude
'Latitude
'CountyCode
'County
'DistrictCode
'District
'WardCode
'Ward
End If
End If
End Sub
// NOTE: The php_soap.dll extension must be enabled in the php.ini file.
function Geocode($licence, $name)
{
$params = array(
"username" => "your-username",
"password" => "your-password",
"licence" => $licence,
"name" => $name,
"options" => $options
);
$client = new SoapClient("http://webservices.data-8.co.uk/Location.asmx?WSDL");
$result = $client->Geocode($params);
if ($result->GeocodeResult->Status->Success == 0)
{
echo "Error: " . $result->GeocodeResult->Status->ErrorMessage;
}
else
{
// TODO: Process method results here.
// Results can be extracted from the following fields:
// $result->GeocodeResult->Results
// Contains the positions of any locations that match the query.
// The position can be extracted from these values in any of three ways:
// 1. Using the Easting and Northing fields, measured in metres east and north
// of the point at 49° N, 2° W.
// 2. Using the GridReference field to get the standard Ordnance Survey grid reference.
// 3. Using the Latitude and Longitude fields to get the location according to
// the selected datum (defaults to WGS84)
// For areas larger than a single postcode, the StdDev field indicates the spread of
// addresses within the area.
// 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->GeocodeResult->Results) as $item)
// {
// ...
// }
}
}