עיגון בעזרת מפות Google

ההארקה באמצעות Google Maps מחברת מודל של Gemini לנתונים גיאו-מרחביים מ-Google Maps, כדי שתוכלו לשלב באפליקציות שלכם פונקציונליות שמבוססת על מיקום.

היתרונות של ביסוס עם Google Maps:

  • שיפור הדיוק העובדתי: כדי לצמצם את ההזיות של המודל, התשובות מבוססות על מסד הנתונים של Google שכולל יותר מ-250 מיליון מקומות ועסקים בעולם האמיתי.
  • גישה למידע בזמן אמת: אפשר לענות על שאלות באמצעות נתונים בזמן אמת, כמו שעות הפעילות הנוכחיות של העסק והסטטוס בזמן אמת של תחנות טעינה לרכב חשמלי.
  • הוספת הקשר חזותי: כדי לבנות את אמון המשתמשים, כדאי לשלב ישירות לצד הטענות מבוססות-המיקום של המודל ווידג'טים אינטראקטיביים של מפות, תמונות ו-Street View.

מודלים נתמכים

  • 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, מספקים את GoogleMaps כtool שהמודל יכול להשתמש בו כדי ליצור את התשובה.

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 (שהיא ברירת המחדל לכל מודלי Gemini 2.5 ואילך). איך מגדירים את רמת האקראיות בהגדרות המודל

שיטות מומלצות וטיפים לשיפור התוצאות

בקטע הזה מפורטות כמה שיטות מומלצות כלליות לשימוש ב-Grounding עם Google Maps, וגם איך להשתמש במאפייני מקום כדי לשפר את התוצאות.

המלצות כלליות

  • מספקים את הכלי רק כשצריך: כדי לבצע אופטימיזציה של הביצועים והעלות, צריך לספק למודל גישה לכלי Grounding with Google Maps רק כשמקרה השימוש כולל הקשר גיאוגרפי ברור.

  • ציון מיקום המשתמש: כדי לקבל תשובות רלוונטיות ומותאמות אישית (וכשהמיקום של המשתמש ידוע), צריך לכלול את המיקום של המשתמש (באמצעות קו רוחב וקו אורך דרך latLng) בהגדרת הכלי Grounding עם Google Maps.

  • הודעה למשתמשי הקצה: צריך להודיע למשתמשי הקצה בצורה ברורה שנתוני Google Maps משמשים למענה על השאילתות שלהם. אספקת המקורות למשתמשי הקצה מ-Google Maps היא דרישה לשימוש בשירות בכלי Grounding with Google Maps.

  • (Web SDK בלבד) הצגת Google Maps הווידג'ט ההקשרי: הווידג'ט ההקשרי מוצג באמצעות טוקן ההקשר, googleMapsWidgetContextToken, שמוחזר בתגובה Gemini API ואפשר להשתמש בו כדי להציג תוכן חזותי מ-Google Maps. מידע נוסף על הווידג'ט ההקשרי זמין במאמר הארקה באמצעות הווידג'ט Google Maps במסמכי התיעוד של Google Maps.

שימוש במאפייני מקום בהנחיות

בקטע הזה מפורטים מאפייני מקום שמשמשים לתיאור מיקומים ומשמשים את Grounding עם Google Maps ליצירת תשובות. המאפיינים האלה משמשים לקביעת סוגי השאלות ש-Google Maps יכול לענות עליהן.

מאפיינים לדוגמה של מקומות

הרשימה הזו כוללת דוגמה של מאפיינים של מקומות, לפי סדר אלפביתי, שהמודל יכול להשתמש בהם כדי ליצור תשובות.

  • כתובת
  • איסוף מדלת העסק
  • כרטיס חיוב מיידי
  • מרחק
  • מגרש חניה בחינם
  • מוזיקה חיה
  • תפריט לילדים
  • שעות פתיחה
  • אפשרויות תשלום (למשל מזומן או כרטיס אשראי)
  • תשובה לשאלה על מקום
  • ידידותי לחיות מחמד
  • מגישים בירה
  • מגישים במקום אוכל צמחוני
  • יש נגישות לכיסא גלגלים
  • Wifi

תשובות לגבי מקומות הן תשובות שנוצרות על ידי Grounding עם Google Maps על סמך מידע שנלקח מביקורות של משתמשים.

הנחיות לדוגמה שמשתמשות במאפייני מקום

בדוגמאות הבאות נעשה שימוש במאפייני מקום בהנחיות לגבי סוגים שונים של מקומות. ההארקה באמצעות Google Maps מתבססת על המאפיינים כדי להבין את הכוונה שלכם, ואז מספקת תשובות רלוונטיות על סמך הנתונים שמשויכים למקומות ב-Google Maps.

  • תכנון ארוחת ערב משפחתית: אפשר לבדוק אם מסעדה מתאימה למשפחות ואם היא מציעה שירותים נוחים.

    • הנחיה לדוגמה: האם מסעדת 'The Italian Place' מתאימה לילדים, והאם יש בה שירות משלוחים? מה הדירוג שלהם?
  • בדיקת הנגישות עבור חבר: אפשר לבדוק אם המקום עונה על צורכי נגישות ספציפיים.

    • הנחיה לדוגמה: אני צריך למצוא מסעדה עם כניסה נגישה לכיסא גלגלים.
  • למצוא מקום לנשנוש בשעות הלילה המאוחרות: למצוא מקום פתוח שמגיש ארוחה ספציפית בשעה מסוימת.

    • הנחיה לדוגמה: Is "Burger Joint" open now? האם מגישים במקום ארוחת ערב? מהן שעות הפתיחה של העסק ביום שישי?
  • פגישה עם לקוח בבית קפה: הערכת ההתאמה של בית קפה לפגישה עסקית על סמך השירותים, המוצרים ואפשרויות התשלום.

    • הנחיה לדוגמה: יש Wi-Fi בבית הקפה 'קפה סנטרל'? האם מגישים במקום הזה קפה? מה רמת המחירים שלהם, והאם הם מקבלים כרטיסי אשראי?

שימו לב: המידע בGoogle Maps תוצאות מבוססות-קרקע עשוי להיות שונה מהתנאים בפועל בכביש.

איך ההארקה עם Google Maps עובדת

כשמספקים למודל את כלי GoogleMaps, המודל מטפל בכל תהליך העבודה של חיפוש, עיבוד וציטוט מידע באופן אוטומטי.

תהליך העבודה של המודל:

  1. קבלת הנחיה: האפליקציה שולחת הנחיה למודל Gemini עם הכלי GoogleMaps מופעל.

  2. ניתוח ההנחיה: המודל מנתח את ההנחיה וקובע אם אפשר לשפר את התשובה, למשל אם ההנחיה מכילה הקשר גיאוגרפי (כמו 'בתי קפה בקרבת מקום', 'מוזיאונים בתל אביב').Google Maps

  3. הפעלת הכלי: המודל, שמזהה את הכוונה הגיאוגרפית, מפעיל את הכלי Google Maps Grounding.

  4. שליחת שאילתות אל Google Maps: שירות ה-Grounding עם Google Maps שולח שאילתות אל Google Maps כדי לקבל מידע רלוונטי (לדוגמה, מקומות, ביקורות, תמונות, כתובות, שעות פתיחה).

    אפשר גם לכלול את קווי הרוחב והאורך בהגדרות של הכלי (או אפילו רק בהנחיה) כדי לקבל תוצאות רלוונטיות יותר ומותאמות אישית.Google Maps הכלי הוא כלי לחיפוש טקסטואלי והוא פועל באופן דומה לחיפוש ב-Google Maps. כלומר, בשאילתות מקומיות (למשל, 'בסביבתי') נעשה שימוש בקואורדינטות, בעוד שבשאילתות ספציפיות או לא מקומיות, לא סביר שהמיקום המפורש ישפיע על התוצאות.

  5. עיבוד התוצאות של Google Maps: המודל מעבד את התוצאות של Google Maps ומנסח תשובה להנחיה המקורית.

  6. מחזיר Google Maps תוצאה מבוססת: המודל מחזיר תשובה סופית וידידותית למשתמש שמבוססת על Google Maps התוצאות. התשובה הזו כוללת:

    • תשובת הטקסט של המודל.
    • אובייקט groundingMetadata עם התוצאות והמקורות Google Maps.
    • (Web SDK בלבד) אסימון googleMapsWidgetContextToken שמאפשר להציג ווידג'ט Google Maps בהקשר באפליקציה לאינטראקציה חזותית. מידע נוסף על הווידג'ט ההקשרי זמין במאמר הארקה באמצעות הווידג'ט Google Maps במסמכי התיעוד של Google Maps.

חשוב לדעת: אם מספקים את Google Maps ככלי למודל, לא בהכרח המודל ישתמש בכלי Google Maps כדי ליצור את התשובה. במקרים כאלה, התשובה לא תכיל אובייקט groundingMetadata ולכן היא לא תוצאה מבוססת Google Maps.

הסבר על התוצאה המבוססת

אם המודל מבסס את התשובה שלו על Google Maps תוצאות, התשובה כוללת אובייקט groundingMetadata שמכיל נתונים מובְנים שחיוניים לאימות טענות ולבניית חוויית מקור עשירה באפליקציה.

אובייקט groundingMetadata בGoogle Maps תוצאה מבוססת מכיל את המידע הבא:

  • groundingChunks: מערך של אובייקטים שמכילים את מקורות maps (uri,‏ placeId ו-title).
  • groundingSupports: מערך של מקטעים לחיבור התגובה של המודל text למקורות ב-groundingChunks. כל מקטע מקשר טקסט segment (מוגדר על ידי startIndex ו-endIndex) ל-groundingChunkIndices אחד או יותר. השדה הזה עוזר לכם ליצור קישורים למקורות בתוך הטקסט. בהמשך הדף מוסבר איך לעמוד בדרישות לשימוש בשירות.
  • (Web SDK בלבד) googleMapsWidgetContextToken: טוקן טקסט שאפשר להשתמש בו כדי לעבד ווידג'ט הקשרי של מקומות. השדה הזה מוחזר רק כשמשתמשים ב-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/..."
      }
    }
  ]
}

דרישות לשימוש בשירות

בקטע הזה מתוארות דרישות השימוש בשירות Grounding עם Google Maps עבור ספק Gemini API שבחרתם: Gemini Developer API או Vertex AI Gemini API (ראו את הקטע תנאי השירות בתנאים הספציפיים לשירות).

הודעה למשתמשים על מקורות Google Maps

בכל Google Maps תוצאה עם ביסוס, תקבלו מקורות ב-groundingChunks שתומכים בכל תשובה. מוחזרים גם המטא-נתונים הבאים:

  • ‫URI במקור
  • כותרת
  • מזהה

כשמציגים תוצאות מ-Grounding עם Google Maps באפליקציה, צריך לציין את המקורות המשויכים של Google Maps ולעדכן את המשתמשים לגבי הדברים הבאים:

  • Google Maps המקורות צריכים להופיע מיד אחרי התוכן שנוצר ושנתמך על ידי המקורות. התוכן שנוצר נקרא גם Google Maps תוצאה מבוססת.

  • צריך לאפשר למשתמש לצפות במקורות Google Maps במהלך אינטראקציה אחת.

כך מקבלים ערכים להצגת מקורות מתוך 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 Maps ו-Google Earth.

Google Maps הנחיות לציון קרדיט לטקסט

כשמציינים את המקורות של Google Maps בתוך הטקסט, חשוב לפעול לפי ההנחיות הבאות:

  • אל תשנו את הטקסט Google Maps בשום צורה:

    • אל תשנו את האותיות הרישיות בטקסט Google Maps.
    • לא להעביר את הטקסט Google Maps לכמה שורות.
    • אל תתאימו את הטקסט Google Maps לשפה אחרת.
    • כדי למנוע מדפדפנים לתרגם את הטקסט Google Maps, צריך להשתמש במאפיין HTML‏ translate="no".
  • מעצבים את הטקסט Google Maps כמו שמתואר בטבלה הבאה:

    נכס סגנון
    משפחת גופנים Roboto. טעינת הגופן היא אופציונלית.
    משפחת גופנים חלופית כל גופן Sans Serif שמשמש כבר במוצר או ‫Sans-Serif כדי להפעיל את גופן המערכת שמוגדר כברירת מחדל
    סגנון הגופן רגיל
    משקל הגופן 400
    צבע גופן לבן, שחור (#1F1F1F) או אפור (#5E5E5E). שומרים על ניגודיות נגישה (4.5:1) ביחס לרקע.
    גודל הגופן גודל גופן מינימלי: 12sp
    גודל גופן מקסימלי: 16sp
    מידע נוסף על sp זמין במאמר בנושא יחידות של גודל גופן באתר Material Design.
    ריווח רגיל

דוגמה ל-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;
}

שמירת טוקן ההקשר ומזהה המקום במטמון

Google Maps התוצאה המבוססת עשויה לכלול אסימון הקשר ומזהה המקום. יכול להיות שתשמרו במטמון, תאחסנו ותייצאו את נתוני התשובה הבאים:

  • (Web SDK בלבד) googleMapsWidgetContextToken
  • placeId

ההגבלות על שמירה במטמון שמפורטות בתנאים של עיגון בעזרת מפות Google לא חלות על הנתונים האלה.

פעילות אסורה ואזורים אסורים

כדי לשמור על בטיחות הפלטפורמה ועל מהימנותה, יש הגבלות נוספות על תוכן ופעילויות מסוימים ב-Google Maps. בנוסף להגבלות על השימוש שמופיעות בתנאים של ספק Gemini API שבחרתם: Gemini Developer API או Vertex AI Gemini API (ראו את הסעיף תנאי השירות בתנאים הספציפיים לשירות).

  • לא תשתמש ב-Grounding עם Google Maps לפעילויות בסיכון גבוה, כולל שירותי תגובה למקרי חירום.

  • לא תפיצו או תשווקו את האפליקציה שלכם שמציעה Grounding עם Google Maps בשטח אסור. מידע נוסף זמין במאמר בנושא אזורים אסורים ב-Google Maps Platform. רשימת הטריטוריות האסורות עשויה להתעדכן מעת לעת.

תוצאות מבוססות-קרקע ומעקב אחרי שימוש בתכונות AI במסוף Firebase

אם הפעלתם מעקב אחרי שימוש בתכונות AI במסוף Firebase, התשובות נשמרות ב-Cloud Logging. כברירת מחדל, תקופת השמירה של הנתונים האלה היא 30 יום.

באחריותכם לוודא שתקופת השמירה הזו, או כל תקופה מותאמת אישית שהגדרתם, תואמת באופן מלא לתרחיש השימוש הספציפי שלכם ולכל דרישות התאימות הנוספות של ספק Gemini API שבחרתם: Gemini Developer API או Vertex AI Gemini API (ראו את הקטע תנאי השירות בתנאים הספציפיים לשירות). יכול להיות שתצטרכו לשנות את תקופת השמירה ב-Cloud Logging כדי לעמוד בדרישות האלה.

תמחור ומגבלות על קצב יצירת הבקשות

ההארקה עם תמחור של Google Maps מבוססת על שאילתות. בקשה נספרת במכסת Google Maps רק אם הנחיה מחזירה בהצלחה לפחות Google Maps תוצאה מבוססת (כלומר, התגובה מכילה לפחות מקור Google Maps). אם נשלחות כמה שאילתות אל Google Maps מבקשה אחת, הן נספרות כבקשה אחת במסגרת מגבלת הקצב.

חשוב לעיין בפרטים על התמחור, הזמינות של המודל והמגבלות של עיגון עם Google Maps במסמכי התיעוד של ספק Gemini API שבחרתם: Gemini Developer API | Vertex AI Gemini API.