پایه‌مندسازی با Google Maps

پایه‌مندسازی با Google Maps قابلیت‌های زایای Gemini را با داده‌های غنی، واقعی، و به‌روز Google Maps متصل می‌کند. این ویژگی به توسعه‌دهندگان امکان می‌دهد عملکرد آگاه از مکان را به‌راحتی در برنامه‌هایشان ادغام کنند. وقتی پرسمان کاربر زمینه‌ای مرتبط با داده‌های Maps داشته باشد، مدل Gemini از Google Maps استفاده می‌کند تا پاسخ‌های دقیق و به‌روزی ارائه دهد که با مکان مشخص‌شده یا منطقه عمومی کاربر مرتبط باشد.

  • پاسخ‌های دقیق و آگاه به مکان: از داده‌های گسترده و به‌روز Google Maps برای پُرسمان‌های جغرافیایی خاص استفاده کنید.
  • شخصی‌سازی بهبودیافته: توصیه‌ها و اطلاعات را براساس مکان‌های ارائه‌شده توسط کاربر سفارشی‌سازی کنید.

شروع کنید

این مثال نشان می‌دهد چگونه «مستندسازی» را با Google Maps در برنامه خودتان یکپارچه کنید تا پاسخ‌های دقیق و مکان‌آگاه به پُرسمان‌های کاربر ارائه دهید. این پیام‌واره توصیه‌های محلی را با مکان اختیاری کاربر درخواست می‌کند و به مدل Gemini امکان می‌دهد از داده‌های Google Maps استفاده کند.

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();

جاوا

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(""));
                }
              }
            }
          }
        }
      }
    }
  }
}

رفتن

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
    }]
  }'

روش کار «پایه‌مندسازی با Google Maps»

پایه‌مندسازی با Google Maps بااستفاده از Maps API به‌عنوان منبع پایه‌مندسازی، Gemini API را با بوم‌سازگان Google Geo یکپارچه می‌کند. وقتی پرسمان کاربر حاوی بافت جغرافیایی باشد، مدل Gemini می‌تواند ابزار «پایه‌گذاری با Google Maps» را فراخوانی کند. سپس مدل می‌تواند پاسخ‌هایی تولید کند که براساس داده‌های Google Maps مرتبط با مکان ارائه‌شده باشد.

این فرایند معمولاً شامل موارد زیر است:

  1. پُرسمان کاربر: کاربر پُرسمانی را به برنامه شما ارسال می‌کند که احتمالاً شامل بافت جغرافیایی است (برای نمونه، «قهوه‌سراهای اطراف من»، «موزه‌های سان‌فرانسیسکو»).
  2. فراخوانی ابزار: مدل Gemini با تشخیص هدف جغرافیایی، ابزار «پایه‌مندسازی با Google Maps» را فراخوانی می‌کند. این ابزار می‌تواند به‌صورت اختیاری با latitude و longitude کاربر ارائه شود. این ابزار یک ابزار جستجوی نوشتاری است و عملکردی مشابه جستجو در Maps دارد، به این صورت که پُرسمان‌های محلی («نزدیک من») از مختصات استفاده می‌کنند، درحالی‌که پُرسمان‌های خاص یا غیرمحلی احتمالاً تحت‌تأثیر مکان صریح قرار نمی‌گیرند.
  3. بازیابی داده‌ها: سرویس «پایه‌گذاری با Google Maps» از Google Maps برای دریافت اطلاعات مرتبط (برای نمونه، مکان‌ها، مرورها، عکس‌ها، نشانی‌ها، ساعات کاری) پُرسمان می‌کند.
  4. تولید مبتنی بر واقعیت: از داده‌های بازیابی‌شده Maps برای اطلاع‌رسانی به پاسخ مدل Gemini استفاده می‌شود و از این طریق دقت و ارتباط واقعی تضمین می‌شود.
  5. پاسخ و گزارمان: مدل پاسخ نوشتاری را با گزارمان‌های به‌خط که به منابع Google Maps پیوند می‌دهند برمی‌گرداند و به توسعه‌دهندگان امکان می‌دهد استنادها را نمایش دهند.

چرا و چه زمانی از «پایه‌مندسازی با Google Maps» استفاده کنیم

«مکان‌یابی با Google Maps» برای برنامه‌هایی که به اطلاعات دقیق، به‌روز، و مکان‌محور نیاز دارند ایده‌آل است. این ویژگی با ارائه محتوای مرتبط و شخصی‌سازی‌شده که از پایگاه داده گسترده Google Maps با بیش‌از ۲۵۰ میلیون مکان در سراسر جهان پشتیبانی می‌شود، تجربه کاربر را بهبود می‌بخشد.

وقتی برنامه‌تان به موارد زیر نیاز دارد باید از «پایه‌مندسازی با Google Maps» استفاده کنید:

  • به سؤالات مربوط به مناطق جغرافیایی پاسخ‌های کامل و دقیق ارائه دهید.
  • برنامه‌ریزهای سفر مکالمه‌ای و راهنمای محلی بسازید.
  • براساس مکان و اولویت‌های کاربر (مثل رستوران‌ها یا فروشگاه‌ها)، نقاط موردعلاقه را توصیه می‌کند.
  • تجربه‌های آگاه از مکان برای خدمات اجتماعی، خرده‌فروشی، یا ارسال غذا ایجاد کنید.

«پایه‌گذاری با Google Maps» در موارد استفاده‌ای که در آن‌ها نزدیکی و داده‌های واقعی فعلی حیاتی است، مثل پیدا کردن «بهترین قهوه‌سرای اطراف من» یا دریافت مسیر، عالی عمل می‌کند.

موارد استفاده

پایه‌مندسازی با Google Maps از موارد استفاده مختلفی که به مکان آگاه هستند پشتیبانی می‌کند.

رسیدگی به سؤالات مختص مکان

درباره مکان خاصی سؤالات دقیق بپرسید تا براساس مرورهای کاربران Google و داده‌های دیگر Maps پاسخ دریافت کنید.

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();

جاوا

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(""));
                }
              }
            }
          }
        }
      }
    }
  }
}

رفتن

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();

جاوا

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(""));
                }
              }
            }
          }
        }
      }
    }
  }
}

رفتن

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();

جاوا

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(""));

رفتن

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 Maps» توضیح می‌دهد.

کاربر را از استفاده از منابع Google Maps مطلع کنید

با هر نتیجه «پایه‌دار» Google Maps، حاشیه‌نویسی‌های منبع را در بلوک‌های محتوای model_output مرحله‌ای که از هر پاسخ پشتیبانی می‌کنند دریافت خواهید کرد. فراداده زیر برگردانده می‌شود:

  • نشانی وب منبع
  • نام

هنگام ارائه نتایج «زمینه‌یابی با Google Maps»، باید منابع Google Maps منسوب را مشخص کنید و کاربران خود را از موارد زیر مطلع کنید:

  • منابع Google Maps باید بلافاصله پس‌از محتوای تولیدشده‌ای که منابع پشتیبانی می‌کنند، ذکر شوند. این محتوای تولیدشده همچنین به‌عنوان «نتیجه زمینه‌ای Google Maps» شناخته می‌شود.
  • منابع Google Maps باید در یک تعامل کاربر قابل‌مشاهده باشند.

نمایش منابع Google Maps با پیوندهای Google Maps

برای هر شرح منبع، پیش‌نمایش پیوند باید با رعایت این الزامات تولید شود:

  • هر منبع را با پیروی از نوشتار Google Maps دستورالعمل‌های اسنادی به Google Maps نسبت دهید.
  • نام منبع ارائه‌شده در پاسخ را نمایش دهید.
  • بااستفاده از url از گزارمان، به منبع پیوند دهید.

رهنمودهای اسنادی نوشتاری Google Maps

وقتی منابع را در متن به Google Maps نسبت می‌دهید، این دستورالعمل‌ها را دنبال کنید:

  • متن Google Maps را به هیچ‌وجه تغییر ندهید:
    • حروف بزرگ Google Maps را تغییر ندهید.
    • ‫Google Maps را در چند خط نپیچید.
    • ‫Google Maps را به زبان دیگری بومی‌سازی نکنید.
    • بااستفاده از ویژگی HTML translate="no"، از ترجمه Google Maps توسط مرورگرها جلوگیری کنید.

برای اطلاعات بیشتر درباره برخی‌از ارائه‌دهندگان داده Google Maps و شرایط پروانه آن‌ها، اعلامیه‌های حقوقی Google Maps و Google Earth را ببینید.

روال‌های مطلوب

  • ارائه مکان کاربر: برای دریافت مرتبط‌ترین و شخصی‌سازی‌شده‌ترین پاسخ‌ها، همیشه latitude و longitude را در پیکربندی ابزار google_maps خودتان وقتی مکان کاربر مشخص است اضافه کنید.
  • به کاربران نهایی اطلاع دهید: به‌طور واضح به کاربران نهایی خود اطلاع دهید که از داده‌های Google Maps برای پاسخ دادن به پُرسمان‌های آن‌ها استفاده می‌شود، به‌ویژه زمانی که ابزار فعال است.
  • خاموش کردن درصورت عدم نیاز: «پایه‌مندسازی با Google Maps» به‌طور پیش‌فرض خاموش است. فقط زمانی آن را فعال کنید ("tools": [{"type": "google_maps"}]) که پُرسمانی زمینه جغرافیایی واضحی داشته باشد تا عملکرد و هزینه را بهینه کنید.

محدودیت‌ها

  • درحال‌حاضر، «پایه‌گذاری با Google Maps» فقط از پیام‌واره‌ها و پاسخ‌های زبان انگلیسی پشتیبانی می‌کند.
  • این ابزار ممکن است در همه مناطق دردسترس نباشد.
  • نتایج ممکن است براساس دقت مکان و داده‌های دردسترس Maps متفاوت باشد.
  • محدوده جغرافیایی: «پایه‌مندسازی با Google Maps» در سراسر جهان دردسترس است.
  • وضعیت پیش‌فرض: ابزار «پایه‌مندسازی با Google Maps» به‌طور پیش‌فرض خاموش است. باید آن را به‌طور صریح در درخواست‌های میانای برنامه‌سازی کاربردی فعال کنید.

قیمت‌گذاری و محدودیت‌های نرخ

قیمت «پایه‌مندسازی با Google Maps» بسته به نسل مدل متفاوت است:

  • Gemini 3 و مدل‌های جدیدتر: هزینه هر پُرسمان جستجویی که مدل تصمیم می‌گیرد اجرا کند به پروژه شما صورت‌حساب می‌شود، با ۵٬۰۰۰ درخواست رایگان در ماه که بین همه مدل‌های Gemini 3 و جدیدتر به‌اشتراک گذاشته می‌شود، و سپس ۱۴ دلار برای هر ۱٬۰۰۰ پُرسمان جستجو. یک پیام‌واره جستجوی واحد (درخواست شما از مدل ازطریق API) ممکن است باعث شود مدل برای یافتن اطلاعات لازم، چندین پُرسمان جستجو را اجرا کند. هریک از این پُرسمان‌ها به‌عنوان استفاده قابل‌پرداخت از ابزار محسوب می‌شود.
  • Gemini 2.5 و مدل‌های قدیمی‌تر: هزینه پروژه شما براساس پیام‌واره جستجو محاسبه می‌شود ‏(۲۵ دلار برای هر ۱٬۰۰۰ پیام‌واره زمینه‌دار). فقط درصورتی هزینه درخواست کسر می‌شود که پیام‌واره حداقل یک نتیجه زمینه‌ای Google Maps را با موفقیت برگرداند، صرف‌نظر از اینکه مدل برای دریافت آن نتیجه چند پُرسمان جستجوی جداگانه در داخل انجام داده است.

سهمیه «پایه‌مندسازی با Google Maps» معمولاً با محدودیت‌های نرخ مدل Gemini زیربنایی مطابقت دارد. برای اطلاعات دقیق درباره قیمت‌گذاری، به صفحه قیمت‌گذاری Gemini API مراجعه کنید.

مدل‌های پشتیبانی‌شده

مدل‌های زیر از «پایه‌مندسازی با Google Maps» پشتیبانی می‌کنند:

مدل پایه‌مندسازی با Google Maps
Gemini 3.8 Flash ✔️
Gemini 3.6 Flash ✔️
Gemini 3.5 Flash-Lite ✔️
پیش‌نمایش 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 ✔️

ترکیب‌های ابزار پشتیبانی‌شده

می‌توانید از «پایه‌گذاری با Google Maps» با ابزارهای داخلی دیگر مثل پایه‌گذاری با «جستجوی Google» (در Gemini 3.5 Flash-Lite و مدل‌های جدیدتر پشتیبانی می‌شود) برای تقویت موارد استفاده پیچیده‌تر استفاده کنید. مدل‌های Gemini 3 همچنین از ترکیب این ابزارهای داخلی با ابزارهای سفارشی (فراخوانی تابع) پشتیبانی می‌کنند. در صفحه ترکیب‌های ابزار بیشتر بدانید.

قدم بعدی چیست