Google マップによるグラウンディングは、Gemini の生成機能と、Google マップの豊富で正確な最新データを結び付けます。この機能により、デベロッパーは位置情報認識機能をアプリケーションに簡単に組み込むことができます。ユーザーのクエリに Google マップデータに関連するコンテキストが含まれている場合、Gemini モデルは Google マップを活用して、ユーザーが指定した場所やおおよその現在地に関連する、事実に基づいた正確で最新の回答を提供します。
- 正確な位置情報認識レスポンス: Google マップの広範で最新のデータを活用して、地理的に特定のクエリに対応します。
- パーソナライズの強化: ユーザーが指定した場所に基づいて、おすすめ情報や情報をカスタマイズします。
- コンテキスト情報とウィジェット: コンテキスト トークンを使用して、生成されたコンテンツとともにインタラクティブな Google マップ ウィジェットをレンダリングします。
始める
この例では、Google マップによるグラウンディングをアプリケーションに統合して、ユーザーのクエリに対して正確な位置情報認識レスポンスを提供する方法を示します。プロンプトは、ユーザーの現在地(省略可)を含むローカルのおすすめ情報をリクエストし、Gemini モデルが Google マップデータを使用できるようにします。
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3-flash-preview",
input="What are the best Italian restaurants within a 15-minute walk from here?",
tools=[{
"type": "google_maps",
"latitude": 34.050481,
"longitude": -118.248526
}]
)
# Print the model's text response and annotations
for step in interaction.steps:
if step.type == "model_output":
for content_block in step.content:
if content_block.type == "text":
print(content_block.text)
if content_block.annotations:
print("\nSources:")
for annotation in content_block.annotations:
if annotation.type == "place_citation":
print(f" - {annotation.name}: {annotation.url}")
JavaScript
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({});
async function main() {
const interaction = await ai.interactions.create({
model: "gemini-3-flash-preview",
input: "What are the best Italian restaurants within a 15-minute walk from here?",
tools: [{
type: "google_maps",
latitude: 34.050481,
longitude: -118.248526
}]
});
// Print the model's text response and annotations
for (const step of interaction.steps) {
if (step.type === 'model_output') {
for (const contentBlock of step.content) {
if (contentBlock.type === 'text') {
console.log(contentBlock.text);
if (contentBlock.annotations) {
console.log("\nSources:");
for (const annotation of contentBlock.annotations) {
if (annotation.type === 'place_citation') {
console.log(` - ${annotation.name}: ${annotation.url}`);
}
}
}
}
}
}
}
}
main();
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "gemini-3-flash-preview",
"input": "What are the best Italian restaurants within a 15-minute walk from here?",
"tools": [{
"type": "google_maps",
"latitude": 34.050481,
"longitude": -118.248526
}]
}'
Google マップによるグラウンディングの仕組み
Google マップによるグラウンディングは、Maps API をグラウンディング ソースとして使用して、Gemini API を Google Geo エコシステムと統合します。ユーザーのクエリに地理的なコンテキストが含まれている場合、Gemini モデルは Google マップによるグラウンディング ツールを呼び出すことができます。その後、モデルは、指定された場所に関連する Google マップデータに基づいてグラウンディングされたレスポンスを生成できます。
このプロセスでは通常、次の処理が行われます。
- ユーザーのクエリ: ユーザーがアプリケーションにクエリを送信します。地理的なコンテキスト(「近くのカフェ」、「サンフランシスコの博物館」など)が含まれる場合があります。
- ツールの呼び出し: Gemini モデルは、地理的な意図を認識して、Google マップによるグラウンディング ツールを呼び出します。このツールには、ユーザーの
latitudeとlongitudeを指定できます(省略可)。このツールはテキスト検索ツールであり、Google マップでの検索と同様に動作します。つまり、ローカル クエリ(「近くの」)では座標が使用されますが、特定のクエリやローカル以外のクエリは明示的な場所の影響を受けにくいです。 - データの取得: Google マップによるグラウンディング サービスは、関連情報(場所、レビュー、写真、住所、営業時間など)について Google マップにクエリを実行します。
- グラウンディングされた生成: 取得した Google マップデータを使用して、Gemini モデルのレスポンスを生成します。これにより、事実の正確性と関連性が確保されます。
- レスポンスとアノテーション: モデルは、Google マップのソースにリンクするインライン アノテーションを含むテキスト レスポンスを返します。これにより、デベロッパーは引用を表示したり、コンテキスト Google マップ ウィジェットをレンダリングしたりできます(省略可)。
Google マップによるグラウンディングを使用する理由とタイミング
Google マップによるグラウンディングは、正確で最新の位置情報が必要なアプリケーションに最適です。世界中の 2 億 5,000 万件を超える場所の Google マップの広範なデータベースに裏付けられた、関連性の高いパーソナライズされたコンテンツを提供することで、ユーザー エクスペリエンスを向上させます。
アプリケーションで次のことが必要な場合は、Google マップによるグラウンディングを使用する必要があります。
- 地理的に特定の質問に対して、完全かつ正確な回答を提供する。
- 会話型の旅行プランナーとローカルガイドを作成する。
- レストランやショップなど、場所やユーザーの好みに基づいておすすめのスポットを提案する。
- ソーシャル、小売、食品配達サービス向けの位置情報認識エクスペリエンスを作成する。
Google マップによるグラウンディングは、「近くの最高のカフェ」を見つける場合や、道順を確認する場合など、近接性と最新の事実データが重要なユースケースに最適です。
ユースケース
Google マップによるグラウンディングは、さまざまな位置情報認識ユースケースをサポートしています。
場所固有の質問の処理
特定の場所について詳細な質問をして、Google ユーザーのレビューやその他の Google マップデータに基づいた回答を得ます。
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3-flash-preview",
input="Is there a cafe near the corner of 1st and Main that has outdoor seating?",
tools=[{
"type": "google_maps",
"latitude": 34.050481,
"longitude": -118.248526
}]
)
for step in interaction.steps:
if step.type == "model_output":
for content_block in step.content:
if content_block.type == "text":
print(content_block.text)
if content_block.annotations:
print("\nSources:")
for annotation in content_block.annotations:
if annotation.type == "place_citation":
print(f" - {annotation.name}: {annotation.url}")
JavaScript
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({});
async function main() {
const interaction = await ai.interactions.create({
model: "gemini-3-flash-preview",
input: "Is there a cafe near the corner of 1st and Main that has outdoor seating?",
tools: [{
type: "google_maps",
latitude: 34.050481,
longitude: -118.248526
}]
});
for (const step of interaction.steps) {
if (step.type === 'model_output') {
for (const contentBlock of step.content) {
if (contentBlock.type === 'text') {
console.log(contentBlock.text);
if (contentBlock.annotations) {
console.log("\nSources:");
for (const annotation of contentBlock.annotations) {
if (annotation.type === 'place_citation') {
console.log(` - ${annotation.name}: ${annotation.url}`);
}
}
}
}
}
}
}
}
main();
位置情報に基づくパーソナライズの提供
ユーザーの好みや特定の地域に合わせてカスタマイズされたおすすめ情報を取得します。
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3-flash-preview",
input="Which family-friendly restaurants near here have the best playground reviews?",
tools=[{
"type": "google_maps",
"latitude": 30.2672,
"longitude": -97.7431
}]
)
for step in interaction.steps:
if step.type == "model_output":
for content_block in step.content:
if content_block.type == "text":
print(content_block.text)
if content_block.annotations:
print("\nSources:")
for annotation in content_block.annotations:
if annotation.type == "place_citation":
print(f" - {annotation.name}: {annotation.url}")
JavaScript
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({});
async function main() {
const interaction = await ai.interactions.create({
model: "gemini-3-flash-preview",
input: "Which family-friendly restaurants near here have the best playground reviews?",
tools: [{
type: "google_maps",
latitude: 30.2672,
longitude: -97.7431
}]
});
for (const step of interaction.steps) {
if (step.type === 'model_output') {
for (const contentBlock of step.content) {
if (contentBlock.type === 'text') {
console.log(contentBlock.text);
if (contentBlock.annotations) {
console.log("\nSources:");
for (const annotation of contentBlock.annotations) {
if (annotation.type === 'place_citation') {
console.log(` - ${annotation.name}: ${annotation.url}`);
}
}
}
}
}
}
}
}
main();
旅程の計画のサポート
さまざまな場所の道順や情報を含む複数日のプランを生成します。旅行アプリに最適です。
Python
from google import genai
client = genai.Client()
prompt = "Plan a day in San Francisco for me. I want to see the Golden Gate Bridge, visit a museum, and have a nice dinner."
interaction = client.interactions.create(
model="gemini-3-flash-preview",
input=prompt,
tools=[{
"type": "google_maps",
"latitude": 37.78193,
"longitude": -122.40476,
"enable_widget": True
}]
)
# ... code to process response and widget token
JavaScript
const interaction = await client.interactions.create({
model: 'gemini-3-flash-preview',
input: 'Plan a day in San Francisco for me. I want to see the Golden Gate Bridge, visit a museum, and have a nice dinner.',
tools: [{
type: "google_maps",
latitude: 37.78193,
longitude: -122.40476,
enableWidget: true
}],
});
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "gemini-3-flash-preview",
"input": "Plan a day in San Francisco for me. I want to see the Golden Gate Bridge, visit a museum, and have a nice dinner.",
"tools": [{
"type": "google_maps",
"latitude": 37.78193,
"longitude": -122.40476,
"enable_widget": true
}]
}'
サービスの使用要件
このセクションでは、Google マップによるグラウンディングのサービス使用要件について説明します。
Google マップのソースの使用についてユーザーに通知する
Google マップのグラウンディングされた結果ごとに、各レスポンスをサポートする model_output ステップのコンテンツ ブロックにソース アノテーションが提供されます。次のメタデータが返されます。
- ソース URL
- name
Google マップによるグラウンディングの結果を表示する場合は、関連する Google マップのソースを指定し、ユーザーに次の情報を通知する必要があります。
- Google マップのソースは、ソースがサポートする生成コンテンツの直後に示す必要があります。この生成されたコンテンツは、Google マップによるグラウンディングの結果ともいいます。
- Google マップのソースは、1 回のユーザー インタラクションで表示できる必要があります。
Google マップへのリンクを含む Google マップのソースを表示する
各ソース アノテーションについて、次の要件に沿ってリンクのプレビューを生成する必要があります。
- Google マップのテキスト 帰属表示のガイドラインに従って、各ソースを Google マップに帰属させます。
- レスポンスで提供されたソース名を表示します。
- アノテーションの
urlを使用してソースにリンクします。
Google マップのテキストでの帰属表示に関するガイドライン
テキストでソースを Google マップに帰属させる場合は、次のガイドラインに従ってください。
- 「Google Maps」というテキストは一切変更しないでください。
- Google Maps の文字の大小は変更しないでください。
- Google Maps を複数行に折り返さないでください。
- Google Maps を他の言語にローカライズしないでください。
- HTML 属性 translate="no" を使用して、ブラウザが Google Maps を翻訳しないようにします。
Google マップのデータ プロバイダとその ライセンス条項について詳しくは、Google マップと Google Earth の法的通知をご覧ください。
ベスト プラクティス
- ユーザーの現在地を指定する: 最も関連性の高いパーソナライズされたレスポンスを得るには、ユーザーの現在地がわかっている場合は、
google_mapsツール構成に常にlatitudeとlongitudeを含めます。 - Google マップ コンテキスト ウィジェットをレンダリングする: コンテキスト ウィジェットは、Gemini API レスポンスで返されるコンテキスト トークン
google_maps_widget_context_tokenを使用してレンダリングされます。このトークンは、Google マップのビジュアル コンテンツのレンダリングに使用できます。 - エンドユーザーに通知する: ツールが有効になっている場合は特に、Google マップデータがクエリの回答に使用されていることをエンドユーザーに明確に通知します。
- 不要な場合はオフにする: Google マップによるグラウンディングはデフォルトでオフになっています。クエリに明確な地理的コンテキストがある場合にのみ有効(
"tools": [{"type": "google_maps"}])にして、パフォーマンスと費用を最適化します。
制限事項
- 現在、Google マップによるグラウンディングは、英語のプロンプトとレスポンスのみをサポートしています。
- 地域によっては、このツールをご利用いただけない場合があります。
- 結果は、位置情報の精度と利用可能な Google マップデータによって異なる場合があります。
- 地理的な範囲: Google マップによるグラウンディングは世界中で利用できます。
- デフォルトの状態: Google マップによるグラウンディング ツールはデフォルトでオフになっています。 API リクエストで明示的に有効にする必要があります。
料金とレート制限
Google マップによるグラウンディングの料金は、クエリに基づいています。現在の料金は グラウンディングされたプロンプト 1,000 件あたり$25 です。無料枠では、1 日あたり最大 500 件のリクエストを利用できます。プロンプトが少なくとも 1 つの Google マップのグラウンディングされた結果(つまり、少なくとも 1 つの Google マップのソースを含む結果)を正常に返した場合にのみ、リクエストが割り当てにカウントされます。1 つのリクエストから複数のクエリが Google マップに送信された場合、レート制限に対して 1 つのリクエストとしてカウントされます。
料金の詳細については、Gemini API の料金ページをご覧ください。
サポートされているモデル
次のモデルは、Google マップによるグラウンディングをサポートしています。
| モデル | Google マップによるグラウンディング |
|---|---|
| Gemini 3.1 Pro プレビュー | ✔️ |
| Gemini 3.1 Flash-Lite | ✔️ |
| Gemini 3.1 Flash-Lite プレビュー | ✔️ |
| Gemini 3 Flash プレビュー | ✔️ |
| Gemini 2.5 Pro | ✔️ |
| Gemini 2.5 Flash | ✔️ |
| Gemini 2.5 Flash-Lite | ✔️ |
| Gemini 2.0 Flash | ✔️ |
サポートされているツールの組み合わせ
Gemini 3 モデルは、組み込みツール(Google マップによるグラウンディングなど)とカスタムツール(関数呼び出し)の組み合わせをサポートしています。詳しくは、 ツールの組み合わせのページをご覧ください。