Search code examples
azure-maps

How can I preserver the Suite/Apt in a call to SearchAddressAsync(string)?


When calling MapSearchClient.SearchAddressAsync(string), if there is a suite or apartment line in the address, it is thrown and not returned in the results.

How can I preserve this to put it in the results? I assume I need to parse the input string, pull the suite/apt if it exists, then assign it to the generated address?


Solution

  • Suite and/or apartment numbers will never be retained by the geocoder. This how most geocoding service work (Other than limited indoor map scenarios, I've never come across a global geocoder that retains this in the 15 years I've been in the geospatial industry). This is primarily since geocoders take your input and return the most likely address that they have in their system, they don't return your parsed input. Unit/apartment/suite numbers are generally not captured in these systems since most address data in global geocoders only go down to building level.

    At best you could possibly try and parse it out yourself if you know the possible combinations of how it might appear in the input address string. You may be able to find an open-source address parsing library that supports this. Here are a few I found that look to support this:

    https://github.com/SwoopSearch/pyaddress

    https://github.com/datamade/usaddress - More info here https://github.com/datamade/usaddress/issues/159