コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
基本的な Place Autocomplete コンポーネント
Places UI キットの Basic Place Autocomplete コンポーネントを使用すると、ユーザーが場所を選択したときにプレイス ID を返す個々の UI コンポーネントを追加できます。このコンポーネントは、ユーザーがクエリを入力するための検索バーを提供する全画面カバーです。ユーザーが入力すると、検索バーの下に予測入力候補のリストが表示されます。ユーザーが場所をタップすると、場所 ID のみを含む場所オブジェクトがデベロッパーに返されます。このコンポーネントはカスタマイズ可能です。
基本的な Place Autocomplete コンポーネントには、リストの密度と位置アイコンを含めるかどうかというカスタマイズ オプションがあります。AutocompleteUICustomization
を使用してコンポーネントをカスタマイズします。
Basic Place Autocomplete コンポーネントは、単独で使用することも、他の Google Maps Platform API やサービスと組み合わせて使用することもできます。
課金
コンポーネントが開いてクエリが実行されるたびに課金されます。セッションが終了するか、リストから場所が選択されない限り、そのセッションに対して再度請求されることはありません。
アプリに基本的なオートコンプリート コンポーネントを追加する
Places UI Kit を使用せずに Place Autocomplete(新版)を使用する場合と同様に、予測入力フィルタ パラメータ(返すタイプ、結果を制限する国、結果の地域座標、距離情報を表示するリクエストのオリジン(利用可能な場合)など)を設定します。手順の詳細と、予測入力フィルタを作成するコードの例については、Place Autocomplete(新版)のドキュメントをご覧ください。
オートコンプリート フィルタを作成したら、UI のカスタマイズを追加します。カスタマイズ オプションと手順をご覧ください。
Kotlin
AutocompleteUiCustomization.create(
listDensity = AutocompleteListDensity.MULTI_LINE,
listItemIcon = AutocompleteUiIcon.noIcon(),
)
Java
AutocompleteUiCustomization.builder()
.listItemIcon(AutocompleteUiIcon.noIcon())
.listDensity(AutocompleteListDensity.MULTI_LINE)
.build()
完全な例をご覧ください。
基本的な予測入力コンポーネントをカスタマイズする
リストの密度
2 行のリストまたは複数行のリストを表示できます。AutocompleteUICustomization
クラスで AutocompleteListDensity
(TWO_LINE
または MULTI_LINE
)のオプションを使用します。リストの密度を指定しない場合、コンポーネントは 2 行のリストを表示します。
位置情報アイコン
検索結果リストにデフォルトのスポット アイコンを表示するかどうかを選択できます。AutocompleteUICustomization
クラスで AutocompleteUIIcon
(listItemDefaultIcon
または noIcon
)のオプションを使用します。
基本的な予測入力コンポーネントにカスタマイズを追加する
AutocompleteUICustomization
クラスを使用して、基本的な自動補完コンポーネントをカスタマイズします。
Kotlin
.setAutocompleteUiCustomization(
AutocompleteUiCustomization.create(
listDensity = AutocompleteListDensity.MULTI_LINE,
listItemIcon = AutocompleteUiIcon.noIcon(),
)
)
Java
.setAutocompleteUiCustomization(
AutocompleteUiCustomization.builder()
.listItemIcon(AutocompleteUiIcon.noIcon())
.listDensity(AutocompleteListDensity.MULTI_LINE)
.build()
)
例
この例では、カスタムの基本的なオートコンプリート コンポーネントを作成します。
Kotlin
val basicPlaceAutocompleteActivityResultLauncher:
ActivityResultLauncher<Intent> =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
result: ActivityResult ->
val intent = result.data
val place: Place? = BasicPlaceAutocomplete.getPlaceFromIntent(intent!!)
val status: Status? =
BasicPlaceAutocomplete.getResultStatusFromIntent(intent!!)
// ...
}
val autocompleteIntent: Intent =
BasicPlaceAutocomplete.createIntent(this) {
setInitialQuery("INSERT_QUERY_TEXT")
setOrigin(LatLng(10.0, 10.0))
// ...
setAutocompleteUiCustomization(
AutocompleteUiCustomization.create(
listDensity = AutocompleteListDensity.MULTI_LINE,
listItemIcon = AutocompleteUiIcon.noIcon(),
)
)
}
basicPlaceAutocompleteActivityResultLauncher.launch(autocompleteIntent)
Java
ActivityResultLauncher<Intent> basicPlaceAutocompleteActivityResultLauncher =
registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(),
new ActivityResultCallback<ActivityResult>() {
@Override
public void onActivityResult(ActivityResult result) {
Intent intent = result.getData();
if (intent != null) {
Place place =
BasicPlaceAutocomplete.getPlaceFromIntent(intent);
Status status =
BasicPlaceAutocomplete.getResultStatusFromIntent(intent);
//...
}
}
}
);
Intent basicPlaceAutocompleteIntent =
new BasicPlaceAutocomplete.IntentBuilder()
.setInitialQuery("INSERT_QUERY_TEXT")
.setOrigin(new LatLng(10.0, 10.0))
//...
.setAutocompleteUiCustomization(
AutocompleteUiCustomization.builder()
.listItemIcon(AutocompleteUiIcon.noIcon())
.listDensity(AutocompleteListDensity.MULTI_LINE)
.build())
.build(this);
basicPlaceAutocompleteActivityResultLauncher.launch(basicPlaceAutocompleteIntent);
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-09-04 UTC。
[null,null,["最終更新日 2025-09-04 UTC。"],[],[],null,["Select platform: [Android](/maps/documentation/places/android-sdk/basic-place-autocomplete-ui-kit \"View this page for the Android platform docs.\") [iOS](/maps/documentation/places/ios-sdk/basic-place-autocomplete-ui-kit \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/places-ui-kit/basic-autocomplete \"View this page for the JavaScript platform docs.\")\n\n\u003cbr /\u003e\n\nBasic Place Autocomplete component\n==================================\n\n\nThe Basic Place Autocomplete component of the Places UI Kit lets you add an individual UI component that returns a [place ID](/maps/documentation/places/android-sdk/place-id) when a user selects a place. The component is a full screen cover that provides a search bar for users to enter a query. As the user types, a list of autocomplete results will be shown below the search bar. When the user taps on a place, a place object with only place ID is returned to the developer. This component is customizable.\n\n\nThe Basic Place Autocomplete component has the following customization options: list density, and whether to include location icons. Use [`AutocompleteUICustomization`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/widget/model/AutocompleteUiCustomization) to customize the component.\n\n\nYou can use the Basic Place Autocomplete component independently or in conjunction with other Google Maps Platform APIs and services.\n\nBilling\n-------\n\n\nYou are billed each time the component is opened and a query is made. You won't be billed again for that session unless the session expires or a place is selected from the list.\n\nAdd the Basic Autocomplete component to your app\n------------------------------------------------\n\n\nSet the autocomplete filter parameters (for example, the types to return, the country to limit results to, the region coordinates for results, the origin of the request to display distance information, if available) as you would to use Place Autocomplete (New) without the Places UI Kit. See the [Place Autocomplete (New) documentation](/maps/documentation/places/android-sdk/place-autocomplete) for full instructions and [an example of the code to create an autocomplete filter](/maps/documentation/places/android-sdk/place-autocomplete#optional-parameters).\n\n\nOnce you've created your autocomplete filter, add your UI customizations. [See customization options and instructions.](/maps/documentation/places/android-sdk/basic-place-autocomplete#customize-the-basic-autocomplete-component) \n\n### Kotlin\n\n```kotlin\nAutocompleteUiCustomization.create(\n listDensity = AutocompleteListDensity.MULTI_LINE,\n listItemIcon = AutocompleteUiIcon.noIcon(),\n)\n```\n\n### Java\n\n```java\n \nAutocompleteUiCustomization.builder()\n .listItemIcon(AutocompleteUiIcon.noIcon())\n .listDensity(AutocompleteListDensity.MULTI_LINE)\n .build()\n```\n\n\n[See the full example](/maps/documentation/places/android-sdk/basic-place-autocomplete-ui-kit#example).\n\nCustomize the Basic Autocomplete component\n------------------------------------------\n\n### List density\n\n\nYou can choose to either display a two-line list or a multiline list. Use the options in `AutocompleteListDensity` (`TWO_LINE` or `MULTI_LINE`) in the [`AutocompleteUICustomization`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/widget/model/AutocompleteUiCustomization) class. If you don't specify the list density, the component will display a two-line list.\n\n### Location icon\n\n\nYou can choose whether to display a default place icon on the results list. Use the options in `AutocompleteUIIcon` (`listItemDefaultIcon` or `noIcon`) in the [`AutocompleteUICustomization`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/widget/model/AutocompleteUiCustomization) class.\n\n### Add customizations to the Basic Autocomplete component\n\n\nUse the [`AutocompleteUICustomization`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/widget/model/AutocompleteUiCustomization) class to customize the Basic Autocomplete component. \n\n### Kotlin\n\n```kotlin\n.setAutocompleteUiCustomization(\n AutocompleteUiCustomization.create(\n listDensity = AutocompleteListDensity.MULTI_LINE,\n listItemIcon = AutocompleteUiIcon.noIcon(),\n )\n)\n```\n\n### Java\n\n```java\n.setAutocompleteUiCustomization(\n AutocompleteUiCustomization.builder()\n .listItemIcon(AutocompleteUiIcon.noIcon())\n .listDensity(AutocompleteListDensity.MULTI_LINE)\n .build()\n)\n```\n\nExample\n-------\n\n\nThis example creates a custom Basic Autocomplete component. \n\n### Kotlin\n\n```kotlin\n val basicPlaceAutocompleteActivityResultLauncher:\n ActivityResultLauncher\u003cIntent\u003e =\n registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {\n result: ActivityResult -\u003e\n val intent = result.data\n val place: Place? = BasicPlaceAutocomplete.getPlaceFromIntent(intent!!)\n val status: Status? = \n BasicPlaceAutocomplete.getResultStatusFromIntent(intent!!)\n // ...\n }\n \n val autocompleteIntent: Intent =\n BasicPlaceAutocomplete.createIntent(this) {\n setInitialQuery(\"INSERT_QUERY_TEXT\")\n setOrigin(LatLng(10.0, 10.0))\n // ...\n \n setAutocompleteUiCustomization(\n AutocompleteUiCustomization.create(\n listDensity = AutocompleteListDensity.MULTI_LINE,\n listItemIcon = AutocompleteUiIcon.noIcon(),\n )\n )\n }\n \n basicPlaceAutocompleteActivityResultLauncher.launch(autocompleteIntent)\n```\n\n### Java\n\n```java\n ActivityResultLauncher\u003cIntent\u003e basicPlaceAutocompleteActivityResultLauncher =\n registerForActivityResult(\n new ActivityResultContracts.StartActivityForResult(),\n new ActivityResultCallback\u003cActivityResult\u003e() {\n @Override\n public void onActivityResult(ActivityResult result) {\n Intent intent = result.getData();\n if (intent != null) {\n Place place =\n BasicPlaceAutocomplete.getPlaceFromIntent(intent);\n Status status =\n BasicPlaceAutocomplete.getResultStatusFromIntent(intent);\n //...\n }\n }\n }\n );\n \n Intent basicPlaceAutocompleteIntent =\n new BasicPlaceAutocomplete.IntentBuilder()\n .setInitialQuery(\"INSERT_QUERY_TEXT\")\n .setOrigin(new LatLng(10.0, 10.0))\n //...\n \n .setAutocompleteUiCustomization(\n AutocompleteUiCustomization.builder()\n .listItemIcon(AutocompleteUiIcon.noIcon())\n .listDensity(AutocompleteListDensity.MULTI_LINE)\n .build())\n .build(this);\n \n basicPlaceAutocompleteActivityResultLauncher.launch(basicPlaceAutocompleteIntent);\n```"]]