Google マップによるグラウンディング

Google Maps によるグラウンディングでは、Gemini モデルを Google Maps の地理空間データに接続して、位置認識機能をアプリに組み込むことができます。

Google Maps を使用したグラウンディングには、次の利点があります。

  • 事実の精度を高める: 2 億 5,000 万を超える現実世界の場所やビジネスに関する Google のデータベースに基づいて回答することで、モデルのハルシネーションを減らします。
  • リアルタイムの情報にアクセスする: 現在の営業時間や EV 充電スタンドのリアルタイムのステータスなどのライブデータを使用して、質問に回答します。
  • 視覚的なコンテキストを提供する: モデルの位置情報に基づく主張の横に、インタラクティブな地図ウィジェット、写真、ストリートビューを直接統合することで、ユーザーの信頼を築きます。

サポートされているモデル

  • gemini-3.1-pro-preview
  • gemini-3-flash-preview
  • gemini-3.1-flash-lite
  • gemini-2.5-pro
  • gemini-2.5-flash
  • gemini-2.5-flash-lite

サポートされている言語

Gemini モデルについては、サポートされている言語をご覧ください。

Google Maps を使用してモデルの根拠づけを行う

Gemini API プロバイダをクリックして、このページでプロバイダ固有のコンテンツとコードを表示します。

GenerativeModel インスタンスを作成するときに、モデルが回答の生成に使用できる tool として GoogleMaps を指定します。

Swift


import FirebaseAILogic

// Initialize the Gemini Developer API backend service
let ai = FirebaseAI.firebaseAI(backend: .googleAI())

// Example: Coordinates for New York City
let latAndLong = CLLocationCoordinate2D(latitude: 40.7128, longitude: -74.0060)

// (Optional) Define a RetrievalConfig to configure the Grounding with Google Maps tool.
// You can optionally provide a location's coordinates and/or a language code
// for more relevant and personalized Google Maps results.
let retrievalConfig = RetrievalConfig(
    location: latAndLong,
    // Example: Language code for English (US)
    languageCode: "en_US"
)

// Wrap the RetrievalConfig inside a ToolConfig.
let toolConfig = ToolConfig(retrievalConfig: retrievalConfig)

// Create a `GenerativeModel` instance with a model that supports your use case.
let model = ai.generativeModel(
    modelName: "GEMINI_MODEL_NAME",
    // Provide Google Maps as a tool that the model can use to generate its response.
    tools: [Tool.googleMaps()],
    // Add the configuration for the Grounding with Google Maps tool
    // (if this optional config was defined above).
    toolConfig: toolConfig
)

let response = try await model.generateContent("restaurants near me?")
print(response.text ?? "No text in response.")

// Make sure to comply with the "Grounding with Google Maps" usage requirements,
// which includes how you meet service usage requirements

Kotlin


// (Optional) Define a RetrievalConfig to configure the Grounding with Google Maps tool.
// You can optionally provide a location's coordinates and/or a language code
// for more relevant and personalized Google Maps results.
val retrievalConfig = RetrievalConfig(
    // Example: Coordinates for New York City
    latLng = LatLng(latitude = 40.7128, longitude = -74.0060),
    // Example: Language code for English (US)
    languageCode = "en_US"
)

// Wrap the RetrievalConfig inside a ToolConfig.
val toolConfig = ToolConfig(
    retrievalConfig = retrievalConfig
)

// Initialize the Gemini Developer API backend service
// Create a `GenerativeModel` instance with a model that supports your use case.
val model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
    modelName = "GEMINI_MODEL_NAME",
    // Add the configuration for the Grounding with Google Maps tool
    // (if this optional config was defined above).
    toolConfig = toolConfig,
    // Provide Google Maps as a tool that the model can use to generate its response.
    tools = listOf(Tool.googleMaps())
)

val response = model.generateContent("restaurants near me?")
print(response.text)

// Make sure to comply with the "Grounding with Google Maps" usage requirements,
// which includes how you meet service usage requirements

Java


// (Optional) Define a ToolConfig to configure the Grounding with Google Maps tool.
// You can optionally provide a location's coordinates and/or a language code
// for more relevant and personalized Google Maps results.
ToolConfig toolConfig = new ToolConfig(
    null,
    new RetrievalConfig(
        // Example: Coordinates for New York City
        new LatLng(40.7128, -74.0060),
        // Example: Language code for English (US)
       "en_US"
    )
);

// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports your use case.
GenerativeModel ai = FirebaseAI.getInstance(GenerativeBackend.googleAI())
                .generativeModel("GEMINI_MODEL_NAME",
                        null,
                        null,
                        // Provide Google Maps as a tool that the model can use to generate its response.
                        List.of(Tool.googleMaps()),
                        // Add the configuration for the Grounding with Google Maps tool
                        // (if this optional config was defined above).
                        toolConfig);

// Use the GenerativeModelFutures Java compatibility layer which offers
// support for ListenableFuture and Publisher APIs.
GenerativeModelFutures model = GenerativeModelFutures.from(ai);

ListenableFuture response = model.generateContent("restaurants near me?");
  Futures.addCallback(response, new FutureCallback() {
      @Override
      public void onSuccess(GenerateContentResponse result) {
          String resultText = result.getText();
          System.out.println(resultText);
      }

      @Override
      public void onFailure(Throwable t) {
          t.printStackTrace();
      }
  }, executor);

// Make sure to comply with the "Grounding with Google Maps" usage requirements,
// which includes how you meet service usage requirements

Web


import { initializeApp } from "firebase/app";
import { getAI, getGenerativeModel, GoogleAIBackend } from "firebase/ai";

// TODO(developer) Replace the following with your app's Firebase configuration
// See: https://firebase.google.com/docs/web/learn-more#config-object
const firebaseConfig = {
  // ...
};

// Initialize FirebaseApp
const firebaseApp = initializeApp(firebaseConfig);

// Initialize the Gemini Developer API backend service
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });

// (Optional) Define a toolConfig to configure the Grounding with Google Maps tool.
// You can optionally provide a location's coordinates and/or a language code
// for more relevant and personalized Google Maps results.
const toolConfig = {
  retrievalConfig: {
    // Example: Coordinates for New York City
    latLng: {
      latitude: 40.7128,
      longitude: -74.0060
    },
    // Example: Language code for English (US)
    languageCode: 'en-US'
  }
};

// Create a `GenerativeModel` instance with a model that supports your use case
const model = getGenerativeModel(
  ai,
  {
    model: "GEMINI_MODEL_NAME",
    // Provide Google Maps as a tool that the model can use to generate its response.
    // (Optional) Set `enableWidget` to control whether the response contains a `googleMapsWidgetContextToken`.
    tools: [ { googleMaps: { enableWidget: true } } ],
    // Add the configuration for the Grounding with Google Maps tool
    // (if this optional config was defined above).
    toolConfig
  }
);

const result = await model.generateContent("restaurants near me?");

console.log(result.response.text());

// Make sure to comply with the "Grounding with Google Maps" usage requirements,
// which includes how you meet service usage requirements

Dart


import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_ai/firebase_ai.dart';
import 'firebase_options.dart';

// Initialize FirebaseApp.
await Firebase.initializeApp(
  options: DefaultFirebaseOptions.currentPlatform,
);

// (Optional) Define a ToolConfig to configure the Grounding with Google Maps tool.
// You can optionally provide a location's coordinates and/or a language code
// for more relevant and personalized Google Maps results.
final toolConfig = ToolConfig(
  retrievalConfig: RetrievalConfig(
    // Example: Coordinates for New York City
    latLng: LatLng(latitude: 40.712728, longitude: -74.006015),
    // Example: Language code for English (US)
    languageCode: 'en',
  ),
);

// Initialize the Gemini Developer API backend service
// Create a `GenerativeModel` instance with a model that supports your use case.
final model = FirebaseAI.googleAI().generativeModel(
  model: 'GEMINI_MODEL_NAME',
  // Provide Google Maps as a tool that the model can use to generate its response.
  tools: [
    Tool.googleMaps(),
  ],
  // Add the configuration for the Grounding with Google Maps tool
  // (if this optional config was defined above).
  toolConfig: toolConfig,
);

final response = await model.generateContent([Content.text("restaurants near me?")]);
print(response.text);

// Make sure to comply with the "Grounding with Google Maps" usage requirements,
// which includes how you meet service usage requirements

Unity


using Firebase;
using Firebase.AI;

// Initialize the Gemini Developer API backend service
var ai = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI());

// Example: Coordinates for New York City
var latLng = new LatLng(40.7128, -74.0060);

// (Optional) Define a RetrievalConfig to configure the Grounding with Google Maps tool.
// You can optionally provide a location's coordinates and/or a language code
// for more relevant and personalized Google Maps results.
var retrievalConfig = new RetrievalConfig(latLng, languageCode: "en");

// Wrap the RetrievalConfig inside a ToolConfig.
var toolConfig = new ToolConfig(retrievalConfig: retrievalConfig);

// Create a `GenerativeModel` instance with a model that supports your use case
var model = ai.GetGenerativeModel(
  modelName: "GEMINI_MODEL_NAME",
  // Provide Google Maps as a tool that the model can use to generate its response.
  tools: new[] { new Tool(new GoogleMaps()) },
  // Add the configuration for the Grounding with Google Maps tool
  // (if this optional config was defined above).
  toolConfig: toolConfig
);

var response = await model.GenerateContentAsync("restaurants near me?");
UnityEngine.Debug.Log(response.Text ?? "No text in response.");

// Make sure to comply with the "Grounding with Google Maps" usage requirements,
// which includes how you meet service usage requirements

ユースケースとアプリに適したモデル を選択する方法について説明します。

最適な結果を得るには、1.0 の Temperature を使用します(これは、Gemini 2.5 以降のすべてのモデルのデフォルトです)。モデルの構成で温度を設定する方法を確認する。

結果を改善するためのベスト プラクティスとヒント

このセクションでは、Google Maps でグラウンディングを使用する際の一般的なベスト プラクティスと、場所のプロパティを活用して結果を改善する方法について説明します。

一般的なおすすめの方法

  • 必要な場合にのみツールを提供する: パフォーマンスと費用を最適化するには、ユースケースに明確な地理的コンテキストがある場合にのみ、Google Maps ツールを使用したグラウンディングへのアクセスをモデルに提供します。

  • ユーザーの位置情報を指定する: 最も関連性の高いパーソナライズされた回答を得るには(ユーザーの位置情報がわかっている場合)、Google Maps ツール構成のグラウンディングにユーザーの位置情報(latLng を使用して緯度と経度を指定)を含めます。

  • エンドユーザーに通知する: Google Maps データがクエリの回答に使用されていることをエンドユーザーに明確に通知します。エンドユーザーに Google Maps のソースを提供することは、Google Maps を使用したグラウンディング ツールのサービス使用要件です。

  • (ウェブ SDK のみ)Google Maps コンテキスト ウィジェットをレンダリングする: コンテキスト ウィジェットは、Gemini API レスポンスで返されるコンテキスト トークン googleMapsWidgetContextToken を使用してレンダリングされます。このトークンは、Google Maps からのビジュアル コンテンツをレンダリングするために使用できます。コンテキスト ウィジェットの詳細については、Google Maps ドキュメントの Google Maps ウィジェットによるグラウンディングをご覧ください。

プロンプトで場所のプロパティを使用する

このセクションでは、場所の説明に使用され、Google Maps のグラウンディングでレスポンスの生成に使用される場所のプロパティについて説明します。これらのプロパティは、Google Maps によるグラウンディングで回答できる質問のタイプを特定するために使用されます。

場所のプロパティの例

このリストは、モデルがレスポンスの生成に使用できる場所に関するプロパティのアルファベット順のサンプルです。

  • 住所
  • ピックアップ
  • デビットカード
  • 距離
  • 無料駐車場
  • 生演奏が楽しめるお店
  • 子供向けメニュー
  • 営業時間
  • お支払い方法(現金、クレジット カードなど)
  • 場所に関する回答
  • ペット OK
  • ビールを出すお店
  • ベジタリアン料理の提供
  • 車椅子対応
  • Wi-Fi

場所の回答は、ユーザーのクチコミから得られた情報に基づいて、Google Maps によるグラウンディングから得られた回答です。

場所のプロパティを使用するプロンプトの例

次の例では、さまざまな種類の場所に関するプロンプトで場所のプロパティを使用しています。Google Maps でのグラウンディングでは、プロパティを使用してユーザーの意図を理解し、Google Maps の場所に関連付けられたデータに基づいて関連性の高い回答を提供します。

  • 家族での夕食を計画する: レストランが家族連れに適しているかどうか、便利なサービスを提供しているかどうかを判断します。

    • プロンプトの例: 「イタリアン プレイス」は子供連れでも大丈夫ですか?テイクアウトはできますか?評価はどのくらいですか?
  • 友人のアクセシビリティを確認する: 特定のアクセシビリティ要件を満たしているかどうかを判断します。

    • プロンプトの例: 車椅子対応の入り口があるレストランを探して。
  • 夜食を食べられる場所を探す: 特定の時間に特定の食事を提供する営業中の店舗を探します。

    • プロンプトの例: 「Burger Joint」は今営業していますか?ディナーは提供していますか?金曜日の営業時間は何時から何時までですか?
  • クライアントとコーヒーを飲む: 設備、提供内容、支払いオプションに基づいて、仕事の打ち合わせに適したカフェかどうかの評価に役立ちます。

    • プロンプト例: 「カフェ セントラル」に Wi-Fi はありますか?コーヒーは飲めますか?価格帯とクレジット カードの利用可否を教えてください。

Google Maps グラウンディングされた検索結果の情報は、道路の実際の状況と異なる場合があります。

Google Maps を使用したグラウンディングの仕組み

GoogleMaps ツールをモデルに提供すると、モデルは情報の検索、処理、引用のワークフロー全体を自動的に処理します。

モデルのワークフローは次のとおりです。

  1. プロンプトを受信: アプリが GoogleMaps ツールを有効にして、Gemini モデルにプロンプトを送信します。

  2. プロンプトを分析する: モデルはプロンプトを分析し、Google Maps が回答を改善できるかどうかを判断します。たとえば、プロンプトに地理的なコンテキスト(「近くのコーヒー ショップ」、「サンフランシスコの美術館」など)が含まれている場合などです。

  3. ツールを呼び出す: モデルは地理的な意図を認識し、Google Maps ツールでグラウンディングを呼び出します。

  4. Google Maps にクエリを送信する: Google Maps を使用したグラウンディング サービスは、関連情報(場所、レビュー、写真、住所、営業時間など)について Google Maps にクエリします。

    必要に応じて、ツールの設定に(またはプロンプトに直接)緯度と経度を含めると、より関連性の高いカスタマイズされた Google Maps 結果が得られます。このツールはテキスト検索ツールであり、Google Maps での検索と同様の動作をします。つまり、ローカル クエリ(「近くの」)では座標が使用されますが、特定のクエリやローカル以外のクエリでは、明示的な位置情報の影響を受けにくいようになっています。

  5. Google Maps の結果を処理する: モデルは Google Maps の結果を処理し、元のプロンプトに対する回答を作成します。

  6. Google Maps グラウンディングされた結果を返す: モデルは、Google Maps の結果に基づいてグラウンディングされた、ユーザー フレンドリーな最終的なレスポンスを返します。このレスポンスの内容は、次のとおりです。

    • モデルのテキスト回答。
    • Google Maps の結果とソースを含む groundingMetadata オブジェクト。
    • (Web SDK のみ)必要に応じて、コンテキストに応じた Google Maps ウィジェットをアプリでレンダリングして視覚的な操作を可能にする googleMapsWidgetContextToken。コンテキスト ウィジェットについて詳しくは、Google Maps ドキュメントの Google Maps ウィジェットを使用したグラウンディングをご覧ください。

Google Maps をモデルのツールとして提供しても、モデルが常に Google Maps ツールを使用してレスポンスを生成する必要はありません。このような場合、レスポンスに groundingMetadata オブジェクトが含まれないため、Google Maps グラウンディングされた結果にはなりません。

グラウンディングされた結果を理解する

モデルが Google Maps の結果に基づいてレスポンスをグラウンディングする場合、レスポンスには groundingMetadata オブジェクトが含まれます。このオブジェクトには、クレームの検証とアプリケーションでのリッチなソース エクスペリエンスの構築に不可欠な構造化データが含まれています。

Google Maps グラウンディングされた結果groundingMetadata オブジェクトには、次の情報が含まれます。

  • groundingChunks: maps ソース(uriplaceIdtitle)を含むオブジェクトの配列。
  • groundingSupports: モデルのレスポンス textgroundingChunks のソースに接続するチャンクの配列。各チャンクは、テキスト segmentstartIndexendIndex で定義)を 1 つ以上の groundingChunkIndices にリンクします。このフィールドは、インラインのソースリンクを構築するのに役立ちます。このページの後半で、サービスの使用要件を満たす方法について説明します。
  • (Web SDK のみ) googleMapsWidgetContextToken: コンテキストに応じた Places ウィジェットのレンダリングに使用できるテキスト トークン。このフィールドは、Web SDK を使用していて、enableWidget パラメータを true に設定している場合にのみ返されます。

groundingMetadata オブジェクトを含むレスポンスの例を次に示します。

{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "text": "CanteenM is an American restaurant with..."
          }
        ],
        "role": "model"
      },
      "groundingMetadata": {
        "groundingChunks": [
          {
            "maps": {
              "uri": "https://maps.google.com/?cid=13100894621228039586",
              "title": "Heaven on 7th Marketplace",
              "placeId": "places/ChIJ0-zA1vBZwokRon0fGj-6z7U"
            }
          }
        ],
        "groundingSupports": [
          {
            "segment": {
              "startIndex": 0,
              "endIndex": 79,
              "text": "CanteenM is an American restaurant with a 4.6-star rating and is open 24 hours."
            },
            "groundingChunkIndices": [0]
          }
        ],
        "googleMapsWidgetContextToken": "widgetcontent/..."
      }
    }
  ]
}

サービスの使用要件

このセクションでは、選択した Gemini API プロバイダ(Gemini Developer API または Vertex AI Gemini API)の Google Maps によるグラウンディングのサービス使用要件について説明します(サービス固有規約のサービス規約セクションを参照)。

Google Maps のソースについてユーザーに通知する

Google Maps グラウンディングされた結果ごとに、各レスポンスをサポートするソースが groundingChunks で提供されます。次のメタデータも返されます。

  • ソースの URI
  • タイトル
  • ID

アプリで Google Maps によるグラウンディングの結果を表示する場合は、関連する Google Maps のソースを指定し、ユーザーに次の情報を通知する必要があります。

  • Google Maps のソースは、ソースがサポートする生成コンテンツの直後に示す必要があります。この生成されたコンテンツは、Google Maps グラウンディングの結果ともいいます。

  • Google Maps のソースは、1 回のユーザー インタラクションで表示できる必要があります。

Google Maps グラウンディングされた結果からソースを表示するための値を取得する方法は次のとおりです。

Swift

// ...

// Get the model's response
let text = response.text

// Get the grounding metadata
if let candidate = response.candidates.first,
   let groundingMetadata = candidate.groundingMetadata {

  // Get sources
  let groundingChunks = groundingMetadata.groundingChunks
  for chunk in groundingChunks {
    if let maps = chunk.maps {
      let title = maps.title  // for example, "Heaven on 7th Marketplace"
      let url = maps.url  // for example, "https://maps.google.com/?cid=13100894621228039586"
      let placeId = maps.placeId  // for example, "places/ChIJ0-zA1vBZwokRon0fGj-6z7U"
      // TODO(developer): show source in the UI
    }
  }
}

Kotlin

// ...

// Get the model's response
val text = response.text

// Get the grounding metadata
val groundingMetadata = response.candidates.firstOrNull()?.groundingMetadata

// Get sources
val groundingChunks = groundingMetadata?.groundingChunks
groundingChunks?.let { chunks ->
  for (chunk in chunks) {
    val title = chunk.maps?.title  // for example, "Heaven on 7th Marketplace"
    val uri = chunk.maps?.uri  // for example, "https://maps.google.com/?cid=13100894621228039586"
    val placeId = chunk.maps?.placeId  // for example, "places/ChIJ0-zA1vBZwokRon0fGj-6z7U"
    // TODO(developer): show source in the UI
  }
}

Java

// ...

Futures.addCallback(response, new FutureCallback() {
  @Override
  public void onSuccess(GenerateContentResponse result) {
    // Get the model's response
    String text = result.getText();

    // Get the grounding metadata
    GroundingMetadata groundingMetadata =
        result.getCandidates()[0].getGroundingMetadata();

    if (groundingMetadata != null) {
      // Get sources
      List chunks = groundingMetadata.getGroundingChunks();
      if (chunks != null) {
        for(GroundingChunk chunk : chunks) {
          GoogleMapsGroundingChunk maps = chunk.getMaps();
          if (maps != null) {
            String title = maps.getTitle();  // for example, "Heaven on 7th Marketplace"
            String uri = maps.getUri();  // for example, "https://maps.google.com/?cid=13100894621228039586"
            String placeId = maps.getPlaceId();  // for example, "places/ChIJ0-zA1vBZwokRon0fGj-6z7U"
            // TODO(developer): show sources in the UI
          }
        }
      }
    }
  }

  @Override
  public void onFailure(Throwable t) {
    t.printStackTrace();
  }
}, executor);

Web

// ...

// Get the model's text response
const text = result.response.text();

// Get the grounding metadata
const groundingMetadata = result.response.candidates?.[0]?.groundingMetadata;

// Get sources
const groundingChunks = groundingMetadata?.groundingChunks;
if (groundingChunks) {
  for (const chunk of groundingChunks) {
    const title = chunk.maps?.title;  // for example, "Heaven on 7th Marketplace"
    const uri = chunk.maps?.uri;  // for example, "https://maps.google.com/?cid=13100894621228039586"
    const placeId = chunk.maps?.placeId;  // for example, "places/ChIJ0-zA1vBZwokRon0fGj-6z7U"
    // TODO(developer): show sources in the UI
  }
}

Dart

// ...

// Get the model's response
final text = response.text;

// Get the grounding metadata
final groundingMetadata = response.candidates.first.groundingMetadata;

// Get sources
final groundingChunks = groundingMetadata?.groundingChunks;
if (groundingChunks != null) {
  for (var chunk in groundingChunks) {
    final title = chunk.maps?.title;  // for example, "Heaven on 7th Marketplace"
    final uri = chunk.maps?.uri;  // for example, "https://maps.google.com/?cid=13100894621228039586"
    final placeId = chunk.maps?.placeId;  // for example, "places/ChIJ0-zA1vBZwokRon0fGj-6z7U"
    // TODO(developer): show sources in the UI
  }
}

Unity

// ...

// Get the model's response
var text = response.Text;

// Get the grounding metadata
var groundingMetadata = response.Candidates.First().GroundingMetadata;

// Get sources
if (groundingMetadata != null) {
  foreach(GroundingChunk chunk in groundingMetadata?.GroundingChunks) {
    if (chunk.Maps != null) {
      var title = chunk.Maps?.Title;  // for example, "Heaven on 7th Marketplace"
      var uri = chunk.Maps?.Uri;  // for example, "https://maps.google.com/?cid=13100894621228039586"
      var placeId = chunk.Maps?.PlaceId;  // for example, "places/ChIJ0-zA1vBZwokRon0fGj-6z7U"
      // TODO(developer): show sources in the UI
    }
  }
}

groundingChunks の各ソースについて、次の要件に沿ってリンクのプレビューを生成する必要があります。

ソースが表示された回答を含むプロンプト

ソースのビューは折りたたむことができます。

プロンプトと回答、ソースが折りたたまれた状態

必要に応じて、リンクのプレビューを次のような追加コンテンツで強化できます。

  • Google Maps テキストの帰属情報の前に挿入された Google Maps ファビコン
  • ソース URL(og:image)の写真。

Google Maps のデータ プロバイダとそのライセンス条項について詳しくは、Google マップと Google Earth の法的通知をご覧ください。

Google Maps テキスト属性のガイドライン

テキスト内でソースを Google Maps に帰属させる場合は、次のガイドラインに従ってください。

  • Google Maps」というテキストは一切変更しないでください。

    • テキスト Google Maps の大文字と小文字は変更しないでください。
    • テキスト Google Maps を複数行に折り返さないでください。
    • テキスト Google Maps を他の言語にローカライズしないでください。
    • HTML 属性 translate="no" を使用して、ブラウザがテキスト Google Maps を翻訳しないようにします。
  • 次の表の説明に従って、テキスト Google Maps のスタイルを設定します。

    プロパティ スタイル
    フォント ファミリー Roboto。フォントの読み込みは任意です。
    代替フォント ファミリー プロダクトですでに使用されている Sans Serif の本文フォント、またはデフォルトのシステム フォントを呼び出すための Sans-Serif
    フォント スタイル 標準
    フォントの太さ 400
    フォントの色 白、黒(#1F1F1F)、グレー(#5E5E5E)。 背景に対してアクセシビリティの高い(4.5:1)コントラストを維持します。
    フォントサイズ 最小フォントサイズ: 12sp
    最大フォントサイズ: 16sp
    sp について詳しくは、マテリアル デザインのウェブサイトでフォントサイズの単位をご覧ください。
    間隔 標準

CSS の例

次の CSS は、白または明るい背景に適切なタイポグラフィ スタイルと色でテキスト Google Maps をレンダリングします。

@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');

.GMP-attribution {
  font-family: Roboto, Sans-Serif;
  font-style: normal;
  font-weight: 400;
  font-size: 1rem;
  letter-spacing: normal;
  white-space: nowrap;
  color: #5e5e5e;
}

コンテキスト トークンと場所 ID のキャッシュ保存

Google Maps グラウンディングされた結果には、コンテキスト トークンとプレイス ID が含まれる場合があります。次のレスポンス データをキャッシュに保存してエクスポートできます。

  • (Web SDK のみ) googleMapsWidgetContextToken
  • placeId

Google マップによるグラウンディングの利用規約に定められているキャッシュ保存の制限は、このデータには適用されません。

禁止される行為と地域

Google Maps でのグラウンディングには、安全で信頼性の高いプラットフォームを維持するため、特定のコンテンツとアクティビティに対する追加の制限があります。選択した Gemini API プロバイダの利用規約に記載されている利用制限に加えて、Gemini Developer API または Vertex AI Gemini API(サービス固有の規約のサービス規約の項を参照)が適用されます。

  • 緊急対応サービスなどの高リスク アクティビティに Google Maps でグラウンディングを使用することはありません。

  • 禁止されている地域で Google Maps によるグラウンディングを提供するアプリケーションを配布または販売しないこと。詳しくは、Google Maps Platform で禁止されている地域をご覧ください。禁止地域の一覧は随時更新される可能性があります。

Firebase コンソールでのグラウンディングされた結果と AI モニタリング

Firebase コンソールで AI モニタリングを有効にしている場合、レスポンスは Cloud Logging に保存されます。デフォルトでは、このデータの保持期間は 30 日間です。

この保持期間または設定したカスタム期間が、特定のユースケースと、選択した Gemini API プロバイダ(Gemini Developer API または Vertex AI Gemini API)の追加のコンプライアンス要件に完全に準拠していることを確認するのは、お客様の責任です(サービス固有の規約のサービス規約のセクションを参照)。これらの要件を満たすには、Cloud Logging の保持期間を調整する必要があります。

料金とレート制限

Google Maps の料金設定によるグラウンディングは、クエリに基づいています。リクエストが Google Maps 割り当てにカウントされるのは、プロンプトが少なくとも 1 つの Google Maps グラウンディングされた結果を正常に返した場合のみです(つまり、レスポンスに少なくとも 1 つの Google Maps ソースが含まれている場合)。1 つのリクエストから Google Maps に複数のクエリが送信された場合、レート上限に対して 1 つのリクエストとしてカウントされます。

選択した Gemini API プロバイダのドキュメント(Gemini Developer API | Vertex AI Gemini API)で、Google Maps を使用したグラウンディングの料金、モデルの可用性、上限の詳細を確認してください。