Looking into this is appears "Prospect place" is the name of the building and not the name of the street the building is on. This is likely the main cause of the issue. The street address for this building is "10 Fairfax Dr, Westcliff-on-Sea". When using the building name the query becomes more of a point of interest search and you might have better luck using a different Azure Maps search service.
As for why you are getting US results, the REST client libraries are currently in preview and were released a few years ago. I believe the search client library is still based on version 1 of the Azure Maps search service powered directly from TomTom which tends to favor US results and has OK address parsing and understanding capabilities. This service sometimes requires tuning the query options to get more accurate results. In this case you can limit the search to a specific country by setting the countrySet
option to GB
. Doing this results in a much better result: Fairfax Drive, Westcliff-on-Sea, SS0
The Azure Maps geocoding service is the next iteration of the search service and is powered by the same data and intelligence as Bing Maps. It is much better at address parsing and understanding, and more globally aligned. Testing all variations of the address you provided with the geocoding service all return the same address:
AddressLatitudeLongitudeFairfax Drive, Westcliff-on-Sea, SS051.5506070.68812This is much more accurate than what you were getting originally and the same result as v1 search service when you limit the search to the UK but without any option tuning needed. The main missing piece here is the street number since the search/geocoding service is only designed for street addresses, it doesn't understand the building name. The geocoding service isn't yet wrapped by a client library, so you would need to call this REST service directly and parse the response. However, keep reading.
Since you have the building name, we can instead use the point of interest search service and we end up getting the exact result you were looking for:
POI NameAddressLatitudeLongitudeProspects Place10 Fairfax Drive, Southend-on-Sea, SS0 9AG51.5503230.702416It does not look like this service is in the REST client library, so you would need to call this REST service directly and parse the results. Here is what the REST query URL would look like:
https://atlas.microsoft.com/search/poi/json?api-version=1.0&query=Prospect%20Place%2C%20Fairfax%20Drive%2C%20Westcliff-on-Sea&view=Auto&subscription-key=
Here is a simple example of how to do this in C#:
string yourAzureMapsKey = "<Insert your Azure Maps Key here>";
string query = "Prospect Place, Fairfax Drive, Westcliff-on-Sea";
var httpClient = new HttpClient();
//Create the request to the Azure Maps Point of Interest. Escape the query as a data string to ensure special characters do not cause issues.
var request = new HttpRequestMessage(HttpMethod.Get, $"https://atlas.microsoft.com/search/poi/json?api-version=1.0&query={Uri.EscapeDataString(query)}&view=Auto&subscription-key={yourAzureMapsKey}");
var response = await httpClient.SendAsync(request);
if (response.StatusCode == System.Net.HttpStatusCode.OK)
{
try
{
var responseBody = await response.Content.ReadAsStringAsync();
//Parse the response and extract the address information.
var json = JsonDocument.Parse(responseBody);
var results = json.RootElement.GetProperty("results");
//Check to see if there is any results.
if (results.GetArrayLength() > 0)
{
//Loop over the results and output the POI name, address, latitude, longitude as a markdown table.
Console.WriteLine("| POI Name | Address | Latitude | Longitude |\n| -------- | ------- | -------- | --------- |");
foreach(var r in results.EnumerateArray())
{
var name = r.GetProperty("poi").GetProperty("name").GetString();
var address = r.GetProperty("address").GetProperty("freeformAddress").GetString();
var position = r.GetProperty("position");
var latitude = position.GetProperty("lat").GetDouble();
var longitude = position.GetProperty("lon").GetDouble();
Console.WriteLine($"| {name} | {address} | {latitude} | {longitude} |");
}
}
else
{
Console.WriteLine("No results found.");
}
}
catch (Exception e)
{
Console.WriteLine("Error parsing response: " + e.Message);
}
}
else
{
Console.WriteLine("Error making request. Status code: " + response.StatusCode);
}