Address Autofill
The Address Autofill 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 Autofill 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 Autofill and other scenarios. We encourage you to install and try it for yourself.
Learn how to integrate Search SDK Address Autofill with UI for suggestions, filled-in form components, and a visual map confirmation (includes Maps SDK) in a sample app.
Integration
Before using any of Mapbox's Search products, complete the installation steps. Then continue with the steps below.
- Create an AddressAutofill instance.
- Request suggestions as the user types and render them in your UI.
- When a suggestion is selected, request full address details and populate form fields.
- Optionally, present a map with a pin for visual confirmation.
- Create an instance of AddressAutofill:
let addressAutofill = AddressAutofill()
- Request suggestions as the user types:
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 suggestion is selected, fetch full address details:
let selectedSuggestion = pickSuggestion(suggestions)
addressAutofill.select(suggestion: selectedSuggestion) { result in
switch result {
case .success(let suggestionResult):
// Use detailed components
let addressComponents = suggestionResult.addressComponents
// populate your UI fields here
case .failure(let error):
print(error)
}
}
For more information, see the full API reference for the iOS Search SDK.
Address Autofill Pricing
There is no separate charge if you choose to use Mapbox Search SDK for iOS to access our APIs—you only pay based on Search API usage.
Usage of Address Autofill is measured in monthly API sessions. Details about the number of API requests included in the free tier and the cost per request beyond what is included in the free tier are available on the pricing page.
For using Address Autofill on the web see our Mapbox Search JS SDK.