Grounding with Google Maps 可将 Gemini 的生成功能与 Google 地图丰富、真实且最新的数据相关联。借助此功能,开发者可以轻松地将位置感知功能融入到自己的应用中。当用户查询与 Google 地图数据相关时,Gemini 模型会利用 Google 地图提供与用户指定位置或大致区域相关的事实准确且最新的回答。
- 准确且能感知位置的回答:利用 Google 地图广泛且最新的数据来回答地理位置特定的查询。
- 增强个性化功能:根据用户提供的位置信息量身定制推荐内容和信息。
开始使用
此示例演示了如何将 Grounding with Google Maps 集成到应用中,以便针对用户查询提供准确且与位置相关的回答。提示要求提供本地推荐,并包含可选的用户位置信息,以便 Gemini 模型使用 Google 地图数据。
Python
# This will only work for SDK newer than 2.0.0
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3.8-flash",
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
// This will only work for SDK newer than 2.0.0
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({});
async function main() {
const interaction = await ai.interactions.create({
model: "gemini-3.8-flash",
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();
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.Annotation;
import com.google.genai.gaos.models.interactions.Content;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.GoogleMaps;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.ModelOutputStep;
import com.google.genai.gaos.models.interactions.PlaceCitation;
import com.google.genai.gaos.models.interactions.Step;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;
Client client = new Client();
CreateModelInteraction params =
CreateModelInteraction.builder()
.model(Model.of("gemini-3.8-flash"))
.input(
InteractionsInput.of(
"What are the best Italian restaurants within a 15-minute walk from here?"))
.tools(
Arrays.asList(
GoogleMaps.builder().latitude(34.050481).longitude(-118.248526).build()))
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
// Print the model's text response and annotations
if (interaction.steps().isPresent()) {
for (Step step : interaction.steps().get()) {
if (step instanceof ModelOutputStep) {
ModelOutputStep outputStep = (ModelOutputStep) step;
if (outputStep.content().isPresent()) {
for (Content contentBlock : outputStep.content().get()) {
if (contentBlock instanceof TextContent) {
TextContent textContent = (TextContent) contentBlock;
System.out.println(textContent.text().orElse(""));
if (textContent.annotations().isPresent()
&& !textContent.annotations().get().isEmpty()) {
System.out.println("\nSources:");
for (Annotation annotation : textContent.annotations().get()) {
if (annotation instanceof PlaceCitation) {
PlaceCitation citation = (PlaceCitation) annotation;
System.out.printf(
" - %s: %s%n", citation.name().orElse(""), citation.url().orElse(""));
}
}
}
}
}
}
}
}
}
Go
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
resp, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(
interactions.CreateModelInteraction{
Model: interactions.Model("gemini-3.8-flash"),
Input: interactions.NewInteractionsInput("What are the best Italian restaurants within a 15-minute walk from here?"),
Tools: []interactions.Tool{
interactions.NewTool(interactions.GoogleMaps{
Latitude: genai.Ptr(34.050481),
Longitude: genai.Ptr(-118.248526),
}),
},
},
),
})
if err != nil {
log.Fatal(err)
}
// Print the model's text response and annotations
for _, step := range resp.Interaction.Steps {
if step.ModelOutputStep != nil {
for _, content := range step.ModelOutputStep.Content {
if content.TextContent != nil {
fmt.Println(content.TextContent.Text)
if len(content.TextContent.Annotations) > 0 {
fmt.Println("\nSources:")
for _, annotation := range content.TextContent.Annotations {
if annotation.PlaceCitation != nil {
c := annotation.PlaceCitation
name := ""
if c.Name != nil {
name = *c.Name
}
url := ""
if c.URL != nil {
url = *c.URL
}
fmt.Printf(" - %s: %s\n", name, url)
}
}
}
}
}
}
}
}
REST
# Specifies the API revision to avoid breaking changes when they become default
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.8-flash",
"input": "What are the best Italian restaurants within a 15-minute walk from here?",
"tools": [{
"type": "google_maps",
"latitude": 34.050481,
"longitude": -118.248526
}]
}'
Grounding with Google Maps 的运作方式
通过使用 Maps API 作为接地源,使用 Google 地图进行接地可将 Gemini API 与 Google 地理位置生态系统相集成。当用户的查询包含地理位置背景信息时,Gemini 模型可以调用“使用 Google 地图建立依据”工具。然后,模型可以根据与所提供位置相关的 Google 地图数据生成回答。
此过程通常包括:
- 用户查询:用户向您的应用提交查询,其中可能包含地理位置背景信息(例如“我附近的咖啡店”“旧金山的博物馆”)。
- 工具调用:Gemini 模型识别出地理位置意图,并调用 Grounding with Google Maps 工具。此工具可以选择性地提供用户的
latitude和longitude。该工具是一个文本搜索工具,其行为与在 Google 地图上搜索类似,即本地查询(例如“我附近”)会使用坐标,而具体或非本地查询不太可能受到明确位置的影响。 - 数据检索:“Grounding with Google Maps”服务会查询 Google 地图以获取相关信息(例如地点、评价、照片、地址、营业时间)。
- 依托数据的生成:检索到的 Google 地图数据用于为 Gemini 模型的回答提供信息,确保回答的事实准确性和相关性。
- 响应和注释:模型会返回一个文本响应,其中包含指向 Google 地图来源的内嵌注释,以便开发者显示引用。
为何及何时使用 Grounding with Google Maps
Grounding with Google Maps 是需要准确、最新且特定于位置的信息的应用的理想之选。它依托 Google 地图在全球范围内超过 2.5 亿个地点的庞大数据库,提供相关且个性化的内容,从而提升用户体验。
如果您的应用需要执行以下操作,则应使用 Grounding with Google Maps 功能:
- 针对特定地理位置的问题提供完整且准确的回答。
- 构建对话式行程规划工具和本地指南。
- 根据位置和用户偏好(例如餐厅或商店)推荐地图注点。
- 为社交、零售或外卖服务打造基于地理位置的体验。
在需要考虑邻近性和当前事实数据的使用场景中,例如查找“我附近的最佳咖啡店”或获取路线,Google 地图的 grounding 功能表现出色。
使用场景
Grounding with Google Maps 支持各种感知位置信息的用例。
处理与地点相关的问题
详细询问特定地点,以根据 Google 用户评价和其他 Google 地图数据获取答案。
Python
# This will only work for SDK newer than 2.0.0
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3.8-flash",
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
// This will only work for SDK newer than 2.0.0
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({});
async function main() {
const interaction = await ai.interactions.create({
model: "gemini-3.8-flash",
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();
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.Annotation;
import com.google.genai.gaos.models.interactions.Content;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.GoogleMaps;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.ModelOutputStep;
import com.google.genai.gaos.models.interactions.PlaceCitation;
import com.google.genai.gaos.models.interactions.Step;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;
Client client = new Client();
CreateModelInteraction params =
CreateModelInteraction.builder()
.model(Model.of("gemini-3.8-flash"))
.input(
InteractionsInput.of(
"Is there a cafe near the corner of 1st and Main that has outdoor seating?"))
.tools(
Arrays.asList(
GoogleMaps.builder().latitude(34.050481).longitude(-118.248526).build()))
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
if (interaction.steps().isPresent()) {
for (Step step : interaction.steps().get()) {
if (step instanceof ModelOutputStep) {
ModelOutputStep outputStep = (ModelOutputStep) step;
if (outputStep.content().isPresent()) {
for (Content contentBlock : outputStep.content().get()) {
if (contentBlock instanceof TextContent) {
TextContent textContent = (TextContent) contentBlock;
System.out.println(textContent.text().orElse(""));
if (textContent.annotations().isPresent()
&& !textContent.annotations().get().isEmpty()) {
System.out.println("\nSources:");
for (Annotation annotation : textContent.annotations().get()) {
if (annotation instanceof PlaceCitation) {
PlaceCitation citation = (PlaceCitation) annotation;
System.out.printf(
" - %s: %s%n", citation.name().orElse(""), citation.url().orElse(""));
}
}
}
}
}
}
}
}
}
Go
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
resp, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(
interactions.CreateModelInteraction{
Model: interactions.Model("gemini-3.8-flash"),
Input: interactions.NewInteractionsInput("Is there a cafe near the corner of 1st and Main that has outdoor seating?"),
Tools: []interactions.Tool{
interactions.NewTool(interactions.GoogleMaps{
Latitude: genai.Ptr(34.050481),
Longitude: genai.Ptr(-118.248526),
}),
},
},
),
})
if err != nil {
log.Fatal(err)
}
for _, step := range resp.Interaction.Steps {
if step.ModelOutputStep != nil {
for _, content := range step.ModelOutputStep.Content {
if content.TextContent != nil {
fmt.Println(content.TextContent.Text)
if len(content.TextContent.Annotations) > 0 {
fmt.Println("\nSources:")
for _, annotation := range content.TextContent.Annotations {
if annotation.PlaceCitation != nil {
c := annotation.PlaceCitation
name := ""
if c.Name != nil {
name = *c.Name
}
url := ""
if c.URL != nil {
url = *c.URL
}
fmt.Printf(" - %s: %s\n", name, url)
}
}
}
}
}
}
}
}
提供基于位置信息的个性化体验
获取根据用户偏好和特定地理区域量身定制的推荐。
Python
# This will only work for SDK newer than 2.0.0
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3.8-flash",
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
// This will only work for SDK newer than 2.0.0
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({});
async function main() {
const interaction = await ai.interactions.create({
model: "gemini-3.8-flash",
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();
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.Annotation;
import com.google.genai.gaos.models.interactions.Content;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.GoogleMaps;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.ModelOutputStep;
import com.google.genai.gaos.models.interactions.PlaceCitation;
import com.google.genai.gaos.models.interactions.Step;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;
Client client = new Client();
CreateModelInteraction params =
CreateModelInteraction.builder()
.model(Model.of("gemini-3.8-flash"))
.input(
InteractionsInput.of(
"Which family-friendly restaurants near here have the best playground reviews?"))
.tools(
Arrays.asList(GoogleMaps.builder().latitude(30.2672).longitude(-97.7431).build()))
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
if (interaction.steps().isPresent()) {
for (Step step : interaction.steps().get()) {
if (step instanceof ModelOutputStep) {
ModelOutputStep outputStep = (ModelOutputStep) step;
if (outputStep.content().isPresent()) {
for (Content contentBlock : outputStep.content().get()) {
if (contentBlock instanceof TextContent) {
TextContent textContent = (TextContent) contentBlock;
System.out.println(textContent.text().orElse(""));
if (textContent.annotations().isPresent()
&& !textContent.annotations().get().isEmpty()) {
System.out.println("\nSources:");
for (Annotation annotation : textContent.annotations().get()) {
if (annotation instanceof PlaceCitation) {
PlaceCitation citation = (PlaceCitation) annotation;
System.out.printf(
" - %s: %s%n", citation.name().orElse(""), citation.url().orElse(""));
}
}
}
}
}
}
}
}
}
Go
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
resp, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(
interactions.CreateModelInteraction{
Model: interactions.Model("gemini-3.8-flash"),
Input: interactions.NewInteractionsInput("Which family-friendly restaurants near here have the best playground reviews?"),
Tools: []interactions.Tool{
interactions.NewTool(interactions.GoogleMaps{
Latitude: genai.Ptr(30.2672),
Longitude: genai.Ptr(-97.7431),
}),
},
},
),
})
if err != nil {
log.Fatal(err)
}
for _, step := range resp.Interaction.Steps {
if step.ModelOutputStep != nil {
for _, content := range step.ModelOutputStep.Content {
if content.TextContent != nil {
fmt.Println(content.TextContent.Text)
if len(content.TextContent.Annotations) > 0 {
fmt.Println("\nSources:")
for _, annotation := range content.TextContent.Annotations {
if annotation.PlaceCitation != nil {
c := annotation.PlaceCitation
name := ""
if c.Name != nil {
name = *c.Name
}
url := ""
if c.URL != nil {
url = *c.URL
}
fmt.Printf(" - %s: %s\n", name, url)
}
}
}
}
}
}
}
}
协助规划行程
生成包含路线和各种位置信息的为期多天的计划,非常适合旅游应用。
Python
# This will only work for SDK newer than 2.0.0
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.8-flash",
input=prompt,
tools=[{
"type": "google_maps",
"latitude": 37.78193,
"longitude": -122.40476
}]
)
# ... code to process response
JavaScript
// This will only work for SDK newer than 2.0.0
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({});
async function main() {
const interaction = await ai.interactions.create({
model: "gemini-3.8-flash",
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
}]
});
}
main();
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.GoogleMaps;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;
Client client = new Client();
String 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.";
CreateModelInteraction params =
CreateModelInteraction.builder()
.model(Model.of("gemini-3.8-flash"))
.input(InteractionsInput.of(prompt))
.tools(
Arrays.asList(GoogleMaps.builder().latitude(37.78193).longitude(-122.40476).build()))
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
// ... code to process response
System.out.println(interaction.outputText().orElse(""));
Go
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
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."
resp, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(
interactions.CreateModelInteraction{
Model: interactions.Model("gemini-3.8-flash"),
Input: interactions.NewInteractionsInput(prompt),
Tools: []interactions.Tool{
interactions.NewTool(interactions.GoogleMaps{
Latitude: genai.Ptr(37.78193),
Longitude: genai.Ptr(-122.40476),
}),
},
},
),
})
if err != nil {
log.Fatal(err)
}
// ... code to process response
fmt.Println(resp.Interaction.GetOutputText())
}
REST
# Specifies the API revision to avoid breaking changes when they become default
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.8-flash",
"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
}]
}'
服务使用要求
本部分介绍了将 Google 地图作为知识库的用例对服务使用情况的要求。
告知用户 Google 地图来源的使用情况
对于每个 Google 地图接地结果,您都会在model_output步骤的内容块中收到来源注释,这些注释支持每个回答。系统会返回以下元数据:
- 来源网址
- name
在展示 Grounding with Google Maps 的结果时,您必须指明关联的 Google 地图来源,并告知用户以下信息:
- Google 地图来源必须紧跟在来源支持的生成内容之后。此类生成的内容也称为 Google 地图接地结果。
- Google 地图来源必须在一次用户互动中可见。
显示包含 Google 地图链接的 Google 地图来源
对于每个来源注释,必须按照以下要求生成链接预览:
- 请按照 Google 地图文字提供方指南,将每项来源归属至 Google 地图。
- 显示回答中提供的来源名称。
- 使用注释中的
url链接到来源。
Google 地图文字提供方信息指南
在文字中将来源归属至 Google 地图时,请遵循以下指南:
- 请勿以任何方式修改“Google 地图”字样:
- 请勿更改“Google 地图”的大小写。
- 请勿将 Google 地图换行显示。
- 请勿将 Google 地图本地化为其他语言。
- 使用 HTML 属性 translate="no" 防止浏览器翻译 Google 地图。
如需详细了解部分 Google 地图数据提供商及其许可条款,请参阅 Google 地图和 Google 地球法律声明。
最佳做法
- 提供用户位置信息:为了获得最相关且个性化的回答,如果知道用户的位置信息,请务必在
google_maps工具配置中添加latitude和longitude。 - 告知最终用户:明确告知最终用户,系统正在使用 Google 地图数据来回答他们的问题,尤其是在该工具处于启用状态时。
- 在不需要时切换为关闭状态:默认情况下,Grounding with Google Maps 处于关闭状态。仅当查询具有明确的地理位置背景信息时才启用此功能 (
"tools": [{"type": "google_maps"}]),以优化性能和费用。
限制
- Grounding with Google Maps 目前仅支持英语提示和回答。
- 此工具可能无法在所有地区使用。
- 结果可能会因位置信息的准确性和可用的 Google 地图数据而异。
- 地理范围:Grounding with Google Maps 在全球范围内可用。
- 默认状态:“依托 Google 地图进行接地”工具默认处于关闭状态。 您必须在 API 请求中明确启用该功能。
价格和速率限制
Grounding with Google Maps 的定价因模型代际而异:
- Gemini 3 模型:系统会针对模型决定执行的每项搜索查询向您的项目收取费用。单个搜索提示(您向模型发出的 API 请求)可能会导致模型执行多次搜索查询,以查找必要的信息。这些查询中的每一项都会计为工具的付费使用。
- Gemini 2.5 及更早版本的模型:您的项目按搜索提示收费。 仅当提示成功返回至少一个 Google 地图接地结果时,才会针对相应请求收费,无论模型在内部执行了多少次单独的搜索查询来获取该结果。
如需详细了解价格信息,请参阅 Gemini API 价格页面。
支持的模型
以下模型支持 Grounding with Google Maps:
| 模型 | 依托 Google 地图进行接地 |
|---|---|
| Gemini 3.8 Flash | ✔️ |
| Gemini 3.7 Flash | ✔️ |
| Gemini 3.6 Flash | ✔️ |
| Gemini 3.5 Flash-Lite | ✔️ |
| Gemini 3.5 Flash | ✔️ |
| Gemini 3.1 Pro 预览版 | ✔️ |
| Gemini 3.1 Flash-Lite | ✔️ |
| Gemini 3 Flash 预览版 | ✔️ |
| Gemini 2.5 Pro | ✔️ |
| Gemini 2.5 Flash | ✔️ |
| Gemini 2.5 Flash-Lite | ✔️ |
支持的工具组合
您可以将 Grounding with Google Maps 与其他内置工具(例如依托 Google 搜索进行接地 [在 Gemini 3.5 Flash 及更高版本的模型上受支持])搭配使用,以实现更复杂的应用场景。Gemini 3 模型还支持将这些内置工具与自定义工具(函数调用)相结合。如需了解详情,请参阅工具组合页面。