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:
- 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.
- 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.
- The user can tap one of the suggested addresses, and the form fields are automatically filled with the selected address.
- 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.
- 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.
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.
Getting Started with Address Form Fill
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.
- To start using the Address Form Fill feature, you first need to get an instance of
AddressAutofill
:
let addressAutofill = AddressAutofill()
- 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)
}
- When a user has selected a suggestion, call
select(suggestion:completion:)
method. This method returns either an error orAddressAutofill.Result
struct that provides detailed information about the address, such asAddressComponents
.
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)
}
}
For more information, see the full API reference for the iOS Search SDK.
For using Address Form Fill on the web see our Mapbox Search JS SDK.