Skip to main content

Address Form Fill

The Address Form Fill feature in the Search SDK is designed to streamline the process of entering a valid home or delivery address. This feature is particularly useful during registration or checkout processes, where a smooth user experience can help prevent churn. By enabling users to fill in the address form by entering only a few characters, you can significantly enhance the user experience.

User experience

The user experience for the Address Form Fill feature in the Search SDK is designed to be intuitive and efficient. Here's how it works:

  1. When it's time to fill in an address in your app, the user is presented with a form. The top field in the form is automatically focused for input.
  2. As the user starts typing, a list of valid, matching addresses is displayed. The addresses closest to the user's current location are presented first.
  3. The user can tap one of the suggested addresses, and the form fields are automatically filled with the selected address.
  4. Your app then displays a map with a pin placed at the selected address. This visual confirmation helps the user make sure that they've selected the correct address.
  5. Users also have the option to add a comment for a housing unit, provide specific delivery instructions, or confirm the address that they would otherwise need to type in manually.

We have a ready-made sample app that you can try in Xcode with Address Form Fill and other scenarios. We encourage you to install and try it for yourself.

example
Full example of Address Form Autofill

Learn how to integrate Search SDK Address Form Fill with UI for suggestions, filled-in form components, and a visual map confirmation (includes Maps SDK) in a sample app.

chevron-right

Getting Started with Address Form Fill

guide
Installation guide

Before using any of Mapbox's Search products, you need to do some common installation steps. Follow this guide, then continue with the steps below.

chevron-right
  1. To start using the Address Form Fill feature, you first need to get an instance of AddressAutofill:
let addressAutofill = AddressAutofill()
  1. Next, you need to add a request for input from the user. Implement a text field or similar UI element in your app where the user can start typing their address. As they type, you can use the AddressAutofill instance to fetch address suggestions.
addressAutofill.suggestions(
for: AddressAutofill.Query(value: yourQueryString)!,
with: AddressAutofill.Options()
) { result in
switch result {
case .success(let suggestions):
show(suggestions)

case .failure(let error):
print(error)
}
  1. When a user has selected a suggestion, call select(suggestion:completion:) method. This method returns either an error or AddressAutofill.Result struct that provides detailed information about the address, such as AddressComponents.
let selectedSuggestion = pickSuggestion(suggestions)
addressAutofill.select(suggestion: selectedSuggestion) { result in
switch result {
case .success(let suggestionResult):
// process result
let addressComponents = suggestionResult.addressComponents

case .failure(let error):
print(error)
}
}

glossary
API Reference

For more information, see the full API reference for the iOS Search SDK.

chevron-right

Want to use Autofill on your website?

For using Address Form Fill on the web see our Mapbox Search JS SDK.

Was this page helpful?