Skip to main content

Address Form Fill

Suppose you need a user to enter a valid home or delivery address. They typically need to do this during the registration or checkout process, where making the entry process as smooth as possible can help you prevent churn. This is where enabling users to fill in the address form by entering only a few characters is the most beneficial.

User experience

  1. Whenever it’s time to fill in the address in your app, the user is presented with a form. The top field in the form is focused for input.
  2. When the user starts typing, a list of valid, matching addresses is displayed, with the addresses closest to the user presented first.
  3. The user taps one of the suggested addresses and the form fields are filled.
  4. Your app shows the map with a pin placed for the selected address, which enables the user to visually confirm that they selected the correct address.
  5. Users also have the option of adding a comment for a housing unit, specific delivery instructions, or confirm the address they otherwise would need to type in manually.

We have a ready-made sample app that you can try in Android Studio with Address Autofill 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 Autofill with UI for suggestions, filled-in form components, and a visual map confirmation (includes Maps SDK) in a sample app.

chevron-right

Integration

Address Autofill provides coroutine-based API. In the following integration steps, we assume that you are familiar with the Kotlin coroutines and your Android project has Kotlin-ktx dependencies added. See the Kotlin coroutines guide for more information.

guide
Installation guide

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

chevron-right
  1. Get instance of AddressAutofill:
val addressAutofill = AddressAutofill.create(mapboxAccessToken)
  1. Add a request for input from the user. There's only one function called suggestions() which has overloadings for different use cases. As was mentioned before, the Address Autofill provides coroutine-based API, and suggestions() is a suspend function which should be called only from a coroutine or another suspend function. In this short example we will assume that we call it from Activity's lifecycleScope:
val query = receivedInput
lifecycleScope.launchWhenCreated {
val response = addressAutofill.suggestions(query, AddressAutofillOptions())
response.onValue { suggestions ->
showSuggestions(suggestions)
}.onError { error ->
// process error
}
}
  1. Process results to fill in the UI fields. When a user has selected a suggestion, call select() function. This function returns AddressAutofillResult object that provides detailed address components.
val suggestion = pickSuggestion(response.suggestions)

val selectionResponse = addressAutofill.select(suggestion)
selectionResponse.onValue { result ->
val resultAddress = result.address
placeField.setText(resultAddress.place)
countryField.setText(resultAddress.country)
}.onError { e ->
// process error
}
glossary
API Reference

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

chevron-right

Address Form Fill Pricing

There is no separate charge if you choose to use Mapbox Search SDK for Android to access our APIs, you only pay by the Search API usage.

Usage of the Address Form Fill 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.


Want to use Autofill on your website?
For using Address Autofill on the web see our Mapbox Search JS SDK.

Was this page helpful?