Why is "locality" field not being returned within address fields in call to get geocodes?

Jeff Haacke 40 Reputation points
2025-03-25T14:23:32.7066667+00:00

I'm calling the "geocode" endpoint, passing in address fields, to get the resolved lat/lon and also address fields back. For some reason with certain Canadian addresses, the "locality" field is not being returned back to me in the result. For example, for the call below, I would expect to get an "address.locality" field back that is set to "Winnipeg". However, this field is missing, although Winnipeg is included in the "formattedAddress" line which I would rather not have to parse. For most other addresses, locality is included in the result. For my use case, I need to rely on the city being included in the result.

geocode?api-version=2025-01-01&subscription-key=###&addressLine=150 McPhillips St&locality=Winnipeg&adminDistrict=MB&postalCode=R3E 2J9

Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
809 questions
0 comments No comments
{count} votes

Accepted answer
  1. rbrundritt 20,201 Reputation points Microsoft Employee
    2025-03-25T15:46:05.58+00:00

    I have been able to reproduce this behavior. I also tested the underlying Bing Maps service used to power this service and it does have the locality property, so it doesn't look like a data issue. I'll pass this to the Azure Maps team so they can investigate this disconnect.

    Note that geocoding services are designed to find the most likely coordinate an address represents on the globe. So if you are using it to try and clean address data, a geocoder is not an ideal solution as it was not designed for that purpose (It does work well for this scenario about 85% of the time). Geocoders shouldn't be used for address validation (e.g. ensuring an address exists) as geocoders will approximate the location of an unknown address which means it can return a successful result for an non-existing address based on approximating on where it should be. (e.g. address 50 is likely in the middle of a section of road with house numbers 1 thru 100).


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.