پایه‌مندسازی با 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)
                            }
                        }
                    }
                }
            }
        }
    }
}

استراحت

# 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())
}

استراحت

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

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

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

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

مدل پایه‌مندسازی با Google Maps
Gemini 4 Argon ✔️
‫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 همچنین از ترکیب این ابزارهای داخلی با ابزارهای سفارشی (فراخوانی تابع) پشتیبانی می‌کنند. در صفحه ترکیب‌های ابزار بیشتر بدانید.

قدم بعدی چیست