Google Maps দিয়ে গ্রাউন্ডিং

গ্রাউন্ডিং উইথ Google Maps একটি জেমিনি মডেলকে Google Maps -এর ভূ-স্থানিক ডেটার সাথে সংযুক্ত করে, যাতে আপনি আপনার অ্যাপগুলিতে অবস্থান-সচেতন কার্যকারিতা যুক্ত করতে পারেন।

Google Maps ব্যবহারের নিম্নলিখিত সুবিধাগুলো রয়েছে:

  • তথ্যগত নির্ভুলতা বৃদ্ধি করুন : গুগলের ২৫ কোটিরও বেশি বাস্তব স্থান ও ব্যবসার ডেটাবেসের উপর ভিত্তি করে প্রতিক্রিয়া তৈরি করে মডেলের বিভ্রম হ্রাস করুন।
  • রিয়েল-টাইম তথ্য অ্যাক্সেস করুন : লাইভ ডেটা ব্যবহার করে প্রশ্নের উত্তর দিন, যেমন বর্তমান ব্যবসায়িক সময় এবং ইভি চার্জিং স্টেশনগুলির রিয়েল-টাইম স্ট্যাটাস।
  • দৃশ্যমান প্রেক্ষাপট প্রদান করুন : মডেলের অবস্থান-ভিত্তিক দাবির পাশাপাশি সরাসরি ইন্টারেক্টিভ ম্যাপ উইজেট, ছবি এবং স্ট্রিট ভিউ যুক্ত করে ব্যবহারকারীর আস্থা তৈরি করুন।

সমর্থিত মডেল

  • gemini-3.1-pro-preview
  • gemini-3.6-flash (এবং পুরোনো gemini-3.5-flash )
  • gemini-3.5-flash-lite (এবং পুরোনো gemini-3.1-flash-lite )

সাধারণ ব্যবহারের জেমিনি ২.৫ মডেলগুলিতে এই সক্ষমতা ছিল, কিন্তু সেগুলি এখন আর ব্যবহৃত হয় না।

সমর্থিত ভাষা

জেমিনি মডেলগুলির জন্য সমর্থিত ভাষাগুলি দেখুন।

Google Maps দিয়ে মডেলটিকে ভিত্তি দিন।

এই পৃষ্ঠায় প্রদানকারী-নির্দিষ্ট বিষয়বস্তু এবং কোড দেখতে আপনার জেমিনি এপিআই প্রদানকারীর উপর ক্লিক করুন।

যখন আপনি GenerativeModel ইনস্ট্যান্সটি তৈরি করবেন, তখন মডেলটির প্রতিক্রিয়া তৈরি করার জন্য একটি tool হিসেবে GoogleMaps প্রদান করুন।

সুইফট


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

ঐক্য


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

কীভাবে একটি মডেল বেছে নিতে হয় তা জানুনআপনার ব্যবহারের ক্ষেত্র এবং অ্যাপের জন্য উপযুক্ত।

ফলাফল উন্নত করার সেরা উপায় ও পরামর্শ

এই বিভাগে Google Maps সাথে গ্রাউন্ডিং ব্যবহারের কিছু সাধারণ সেরা অনুশীলন এবং ফলাফল উন্নত করার জন্য স্থানের বৈশিষ্ট্যগুলো কীভাবে কাজে লাগানো যায়, তা বর্ণনা করা হয়েছে।

সাধারণ সর্বোত্তম অনুশীলন

  • শুধুমাত্র প্রয়োজনের সময় টুলটি সরবরাহ করুন : কর্মক্ষমতা এবং খরচ অপ্টিমাইজ করতে, মডেলটিকে 'গ্রাউন্ডিং উইথ Google Maps টুলটিতে অ্যাক্সেস কেবল তখনই দিন যখন ব্যবহারের ক্ষেত্রটির একটি স্পষ্ট ভৌগোলিক প্রেক্ষাপট থাকে।

  • ব্যবহারকারীর অবস্থান প্রদান করুন : সবচেয়ে প্রাসঙ্গিক এবং ব্যক্তিগতকৃত প্রতিক্রিয়ার জন্য (এবং যখন ব্যবহারকারীর অবস্থান জানা থাকে), ‘গ্রাউন্ডিং উইথ Google Maps টুলের কনফিগারেশনে ব্যবহারকারীর অবস্থান ( latLng এর মাধ্যমে অক্ষাংশ এবং দ্রাঘিমাংশ ব্যবহার করে) অন্তর্ভুক্ত করুন।

  • ব্যবহারকারীদের অবহিত করুন : আপনার ব্যবহারকারীদের স্পষ্টভাবে জানান যে তাদের জিজ্ঞাসার উত্তর দিতে Google Maps ডেটা ব্যবহার করা হচ্ছে। ‘গ্রাউন্ডিং উইথ Google Maps টুলটির জন্য ব্যবহারকারীদের কাছে Google Maps থেকে ডেটার উৎস সরবরাহ করা একটি আবশ্যিক পরিষেবা

  • (শুধুমাত্র ওয়েব SDK-এর জন্য) Google Maps কনটেক্সচুয়াল উইজেট রেন্ডার করুন : কনটেক্সচুয়াল উইজেটটি কনটেক্সট টোকেন, googleMapsWidgetContextToken , ব্যবহার করে রেন্ডার করা হয়, যা জেমিনি এপিআই রেসপন্সে ফেরত আসে এবং Google Maps থেকে ভিজ্যুয়াল কন্টেন্ট রেন্ডার করতে ব্যবহার করা যায়। কনটেক্সচুয়াল উইজেট সম্পর্কে আরও তথ্যের জন্য, Google Maps ডকুমেন্টেশনে "গ্রাউন্ডিং উইথ Google Maps উইজেট" দেখুন।

প্রম্পটে স্থানের বৈশিষ্ট্য ব্যবহার করুন

এই বিভাগে স্থানের সেই বৈশিষ্ট্যগুলো তালিকাভুক্ত করা হয়েছে, যেগুলো অবস্থান বর্ণনা করতে এবং ‘গ্রাউন্ডিং উইথ Google Maps দ্বারা প্রতিক্রিয়া তৈরি করতে ব্যবহৃত হয়। এই বৈশিষ্ট্যগুলো ‘গ্রাউন্ডিং উইথ Google Maps কোন ধরনের প্রশ্নের উত্তর দিতে পারবে, তা নির্ধারণ করতে ব্যবহৃত হয়।

নমুনা স্থানের বৈশিষ্ট্য

এই তালিকাটি স্থান সম্পর্কিত এমন কিছু বৈশিষ্ট্যের বর্ণানুক্রমিক নমুনা প্রদান করে, যা আপনার মডেল প্রতিক্রিয়া তৈরি করতে ব্যবহার করতে পারে।

  • ঠিকানা
  • কার্বসাইড পিকআপ
  • ডেবিট কার্ড
  • দূরত্ব
  • বিনামূল্যে পার্কিং লট
  • লাইভ সঙ্গীত
  • শিশুদের জন্য মেনু
  • খোলার সময়
  • অর্থপ্রদানের বিকল্প (যেমন নগদ বা ক্রেডিট কার্ড )
  • উত্তর দিন
  • পোষা প্রাণীবান্ধব
  • বিয়ার পরিবেশন করে
  • নিরামিষ খাবার পরিবেশন করা হয়
  • হুইলচেয়ার প্রবেশযোগ্য
  • ওয়াইফাই

প্লেস অ্যানসারস হলো গ্রাউন্ডিং উইথ Google Maps পক্ষ থেকে ব্যবহারকারীদের রিভিউ থেকে প্রাপ্ত তথ্যের উপর ভিত্তি করে দেওয়া একটি প্রতিক্রিয়া।

স্থান বৈশিষ্ট্য ব্যবহার করে এমন উদাহরণ প্রম্পট।

নিম্নলিখিত উদাহরণগুলিতে বিভিন্ন ধরণের স্থান সম্পর্কিত নির্দেশনায় স্থানের বৈশিষ্ট্য ব্যবহার করা হয়েছে। গ্রাউন্ডিং উইথ Google Maps আপনার উদ্দেশ্য বোঝার জন্য এই বৈশিষ্ট্যগুলি ব্যবহার করে এবং তারপরে Google Maps এর স্থানগুলির সাথে সম্পর্কিত ডেটার উপর ভিত্তি করে প্রাসঙ্গিক উত্তর প্রদান করে।

  • পারিবারিক নৈশভোজের পরিকল্পনা করুন : রেস্তোরাঁটি পরিবারের জন্য উপযুক্ত কিনা এবং সেখানে সুবিধাজনক পরিষেবা দেওয়া হয় কিনা তা যাচাই করুন।

    • উদাহরণস্বরূপ প্রশ্ন: "দ্য ইতালিয়ান প্লেস" কি বাচ্চাদের জন্য ভালো, এবং তারা কি টেকআউট পরিষেবা দেয়? তাদের রেটিং কত?
  • বন্ধুর জন্য প্রবেশগম্যতা যাচাই করুন : স্থানটি নির্দিষ্ট প্রবেশগম্যতার চাহিদা পূরণ করে কিনা তা নির্ধারণ করুন।

    • উদাহরণস্বরূপ জিজ্ঞাসা: আমার এমন একটি রেস্তোরাঁ প্রয়োজন যার প্রবেশপথ হুইলচেয়ার ব্যবহারকারীদের জন্য প্রবেশযোগ্য।
  • গভীর রাতের নাস্তার জন্য একটি জায়গা খুঁজুন : এমন একটি খোলা প্রতিষ্ঠান খুঁজুন যেখানে একটি নির্দিষ্ট সময়ে একটি নির্দিষ্ট খাবার পরিবেশন করা হয়।

    • উদাহরণস্বরূপ প্রশ্ন: "বার্গার জয়েন্ট" কি এখন খোলা আছে? ওরা কি রাতের খাবার পরিবেশন করে? শুক্রবারে ওদের খোলার সময়সূচী কী?
  • ক্লায়েন্টের সাথে কফি খেতে সাক্ষাৎ : সুযোগ-সুবিধা, প্রদত্ত পরিষেবা এবং অর্থ পরিশোধের পদ্ধতির উপর ভিত্তি করে একটি ব্যবসায়িক বৈঠকের জন্য ক্যাফেটির উপযুক্ততা মূল্যায়ন করুন।

    • উদাহরণস্বরূপ প্রশ্ন: "ক্যাফে সেন্ট্রাল"-এ কি ওয়াইফাই আছে? তারা কি কফি পরিবেশন করে? তাদের মূল্যস্তর কেমন, এবং তারা কি ক্রেডিট কার্ড গ্রহণ করে?

মনে রাখবেন যে, Google Maps বাস্তব ফলাফলের তথ্য রাস্তার প্রকৃত অবস্থা থেকে ভিন্ন হতে পারে।

Google Maps দিয়ে গ্রাউন্ডিং কীভাবে কাজ করে

যখন আপনি মডেলটিকে GoogleMaps টুলটি প্রদান করেন, তখন মডেলটি স্বয়ংক্রিয়ভাবে তথ্য অনুসন্ধান, প্রক্রিয়াকরণ এবং উদ্ধৃতি দেওয়ার সম্পূর্ণ কার্যপ্রবাহটি পরিচালনা করে।

মডেলটির কার্যপ্রবাহ নিচে দেওয়া হলো:

  1. প্রম্পট গ্রহণ করে : আপনার অ্যাপটি GoogleMaps টুল সক্রিয় থাকা জেমিনি মডেলে একটি প্রম্পট পাঠায়।

  2. প্রম্পট বিশ্লেষণ করে : মডেলটি প্রম্পটটি বিশ্লেষণ করে এবং নির্ধারণ করে যে Google Maps তার প্রতিক্রিয়া উন্নত করতে পারে কিনা, উদাহরণস্বরূপ, যদি প্রম্পটটিতে ভৌগোলিক প্রসঙ্গ থাকে (যেমন "আমার কাছাকাছি কফি শপ," "সান ফ্রান্সিসকোর জাদুঘর")।

  3. টুলটি চালু করে : মডেলটি ভৌগোলিক অভিপ্রায় শনাক্ত করে ‘গ্রাউন্ডিং উইথ Google Maps টুলটি চালু করে।

  4. Google Maps এ অনুসন্ধান পাঠায় : ‘গ্রাউন্ডিং উইথ Google Maps পরিষেবাটি প্রাসঙ্গিক তথ্যের (যেমন, স্থান, পর্যালোচনা, ছবি, ঠিকানা, খোলার সময়) জন্য Google Maps অনুসন্ধান করে।

    আরও প্রাসঙ্গিক এবং ব্যক্তিগতকৃত Google Maps ফলাফল পেতে, আপনি ঐচ্ছিকভাবে টুলটির কনফিগে (অথবা সরাসরি প্রম্পটেও) অক্ষাংশ এবং দ্রাঘিমাংশ অন্তর্ভুক্ত করতে পারেন। টুলটি একটি টেক্সচুয়াল সার্চ টুল এবং এটি Google Maps সার্চ করার মতোই কাজ করে; অর্থাৎ, স্থানীয় অনুসন্ধানের ("আমার কাছাকাছি") ক্ষেত্রে স্থানাঙ্ক ব্যবহার করা হয়, কিন্তু নির্দিষ্ট বা অস্থানীয় অনুসন্ধানের ক্ষেত্রে সুস্পষ্ট অবস্থান দ্বারা প্রভাবিত হওয়ার সম্ভাবনা কম।

  5. Google Maps ফলাফল প্রক্রিয়াকরণ : মডেলটি Google Maps ফলাফল প্রক্রিয়াকরণ করে এবং মূল নির্দেশনার একটি প্রতিক্রিয়া তৈরি করে।

  6. Google Maps -ভিত্তিক ফলাফল প্রদান করে : মডেলটি একটি চূড়ান্ত, ব্যবহারকারী-বান্ধব প্রতিক্রিয়া প্রদান করে যা Google Maps ফলাফলের উপর ভিত্তি করে তৈরি। এই প্রতিক্রিয়ায় অন্তর্ভুক্ত থাকে:

    • মডেলের টেক্সট উত্তর।
    • একটি groundingMetadata অবজেক্ট, যাতে Google Maps ফলাফল এবং উৎসগুলো রয়েছে।
    • (শুধুমাত্র ওয়েব এসডিকে-এর জন্য) ঐচ্ছিকভাবে একটি googleMapsWidgetContextToken, যা আপনাকে ভিজ্যুয়াল ইন্টারঅ্যাকশনের জন্য আপনার অ্যাপে একটি প্রাসঙ্গিক Google Maps উইজেট রেন্ডার করতে দেয়। প্রাসঙ্গিক উইজেট সম্পর্কে আরও তথ্যের জন্য, Google Maps ডকুমেন্টেশনে "গ্রাউন্ডিং উইথ Google Maps উইজেট" দেখুন।

উল্লেখ্য যে, মডেলে একটি টুল হিসেবে Google Maps প্রদান করার অর্থ এই নয় যে, মডেলটিকে তার প্রতিক্রিয়া তৈরি করার জন্য সর্বদা Google Maps টুলটিই ব্যবহার করতে হবে। এই ক্ষেত্রে, প্রতিক্রিয়াটিতে কোনো groundingMetadata অবজেক্ট থাকবে না এবং তাই এটি একটি Google Maps গ্রাউন্ডেড রেজাল্ট নয়

বাস্তব ফলাফলটি বুঝুন

যদি মডেলটি Google Maps ফলাফলের উপর ভিত্তি করে তার প্রতিক্রিয়া তৈরি করে, তাহলে সেই প্রতিক্রিয়ায় একটি groundingMetadata অবজেক্ট অন্তর্ভুক্ত থাকে। এই অবজেক্টটিতে এমন কাঠামোগত ডেটা থাকে যা দাবি যাচাই করার জন্য এবং আপনার অ্যাপ্লিকেশনে একটি সমৃদ্ধ উৎস অভিজ্ঞতা তৈরি করার জন্য অপরিহার্য।

Google Maps গ্রাউন্ডেড রেজাল্টের মধ্যে থাকা groundingMetadata অবজেক্টটিতে নিম্নলিখিত তথ্য থাকে:

  • groundingChunks : অবজেক্টের একটি অ্যারে, যেখানে maps উৎসগুলো ( uri , placeId , এবং title ) থাকে।
  • groundingSupports : মডেল রেসপন্স text groundingChunks এর সোর্সগুলোর সাথে সংযুক্ত করার জন্য চাঙ্কগুলোর একটি অ্যারে। প্রতিটি চাঙ্ক একটি টেক্সট segment (যা startIndex এবং endIndex দ্বারা সংজ্ঞায়িত) এক বা একাধিক groundingChunkIndices এর সাথে লিঙ্ক করে। এই ফিল্ডটি আপনাকে ইনলাইন সোর্স লিঙ্ক তৈরি করতে সাহায্য করে। এই পৃষ্ঠার পরবর্তী অংশে জানুন কীভাবে সার্ভিস ব্যবহারের প্রয়োজনীয়তাগুলো পূরণ করতে হয়।
  • (শুধুমাত্র ওয়েব এসডিকে-এর জন্য) googleMapsWidgetContextToken : একটি টেক্সট টোকেন যা একটি প্রাসঙ্গিক প্লেসেস উইজেট রেন্ডার করতে ব্যবহার করা যেতে পারে। এই ফিল্ডটি শুধুমাত্র ওয়েব এসডিকে ব্যবহার করার সময় এবং যদি আপনি enableWidget প্যারামিটারটি true সেট করে থাকেন, তবেই ফেরত আসে।

এখানে একটি উদাহরণ প্রতিক্রিয়া দেওয়া হল, যাতে একটি groundingMetadata অবজেক্ট অন্তর্ভুক্ত রয়েছে:

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

পরিষেবা ব্যবহারের প্রয়োজনীয়তা

এই বিভাগে আপনার নির্বাচিত Gemini API প্রদানকারী— Gemini Developer API অথবা Agent Platform Gemini API (পূর্বে Vertex AI)— এর জন্য Grounding with Google Maps এর পরিষেবা ব্যবহারের প্রয়োজনীয়তা বর্ণনা করা হয়েছে (পরিষেবা নির্দিষ্ট শর্তাবলীর মধ্যে পরিষেবা শর্তাবলী বিভাগটি দেখুন)।

Google Maps ব্যবহারকারীদের উৎস সম্পর্কে অবহিত করুন।

প্রতিটি Google Maps গ্রাউন্ডেড রেজাল্ট-এর সাথে, আপনি groundingChunks এ সেই সোর্সগুলো পাবেন যা প্রতিটি রেসপন্সকে সাপোর্ট করে। এছাড়াও নিম্নলিখিত মেটাডেটা ফেরত দেওয়া হয়:

  • উৎস ইউআরআই
  • শিরোনাম
  • আইডি

আপনার অ্যাপে, ‘গ্রাউন্ডিং উইথ Google Maps থেকে প্রাপ্ত ফলাফল দেখানোর সময়, আপনাকে অবশ্যই সংশ্লিষ্ট Google Maps উৎসগুলো উল্লেখ করতে হবে এবং আপনার ব্যবহারকারীদের নিম্নলিখিত বিষয়গুলো সম্পর্কে জানাতে হবে:

  • Google Maps সোর্সগুলোকে অবশ্যই সেই সোর্স-সমর্থিত জেনারেটেড কন্টেন্টের ঠিক পরেই থাকতে হবে। এই জেনারেটেড কন্টেন্টকে Google Maps গ্রাউন্ডেড রেজাল্ট নামেও উল্লেখ করা হয়।

  • Google Maps উৎসগুলো অবশ্যই একটিমাত্র ব্যবহারকারী ইন্টারঅ্যাকশনের মধ্যেই দেখার যোগ্য হতে হবে।

Google Maps গ্রাউন্ডেড রেজাল্ট থেকে সোর্স প্রদর্শনের জন্য ভ্যালুগুলো যেভাবে পাবেন, তা নিচে দেওয়া হলো:

সুইফট

// ...

// 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
  }
}

ঐক্য

// ...

// 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 কে দিন।
  • প্রতিক্রিয়ায় প্রদত্ত উৎসের শিরোনামটি প্রদর্শন করুন।
  • রেসপন্স থেকে প্রাপ্ত uri ব্যবহার করে সোর্সের সাথে লিঙ্ক করুন।

উৎস দেখানো সহ প্রতিক্রিয়া জানান।

আপনি উৎসগুলোর দৃশ্য সংকুচিত করতে পারেন।

প্রতিক্রিয়া এবং উৎস সহ প্রম্পটটি ভেঙে গেছে

ঐচ্ছিকভাবে, আপনি অতিরিক্ত বিষয়বস্তু দিয়ে লিঙ্ক প্রিভিউটিকে আরও উন্নত করতে পারেন, যেমন:

  • Google Maps টেক্সট অ্যাট্রিবিউশনের আগে একটি Google Maps ফেভিকন যুক্ত করা হয়েছে।
  • উৎস ইউআরএল ( og:image ) থেকে প্রাপ্ত একটি ছবি।

Google Maps এর কিছু ডেটা সরবরাহকারী এবং তাদের লাইসেন্সের শর্তাবলী সম্পর্কে আরও তথ্যের জন্য, গুগল ম্যাপস ও গুগল আর্থ-এর আইনি বিজ্ঞপ্তিগুলো দেখুন।

Google Maps টেক্সট অ্যাট্রিবিউশন নির্দেশিকা

লেখার মধ্যে Google Maps এর উৎস উল্লেখ করার সময় এই নির্দেশিকাগুলো অনুসরণ করুন:

  • Google Maps লেখাটি কোনোভাবেই পরিবর্তন করবেন না:

    • Google Maps লেখাটির বড় হাতের অক্ষরের ব্যবহার পরিবর্তন করবেন না।
    • Google Maps লেখাটি একাধিক লাইনে রাখবেন না।
    • Google Maps লেখাটি অন্য কোনো ভাষায় স্থানীয়করণ করবেন না।
    • HTML অ্যাট্রিবিউট translate="no" ব্যবহার করে ব্রাউজারকে Google Maps লেখাটির অনুবাদ করা থেকে বিরত রাখুন।
  • নিম্নলিখিত সারণিতে বর্ণিত পদ্ধতি অনুসারে Google Maps টেক্সটটি স্টাইল করুন:

    সম্পত্তি শৈলী
    ফন্ট পরিবার রোবোটো। ফন্টটি লোড করা ঐচ্ছিক।
    ফলব্যাক ফন্ট পরিবার আপনার পণ্যে ইতিমধ্যে ব্যবহৃত যেকোনো স্যান্স সেরিফ বডি ফন্ট অথবা ডিফল্ট সিস্টেম ফন্ট চালু করার জন্য "Sans-Serif" ব্যবহার করুন।
    ফন্ট শৈলী স্বাভাবিক
    ফন্টের ওজন ৪০০
    ফন্টের রঙ সাদা, কালো (#1F1F1F), অথবা ধূসর (#5E5E5E)। পটভূমির সাথে সুলভ (৪.৫:১) বৈসাদৃশ্য বজায় রাখুন।
    ফন্টের আকার সর্বনিম্ন ফন্ট সাইজ: ১২sp
    সর্বোচ্চ ফন্ট সাইজ: ১৬sp
    sp সম্পর্কে জানতে, ম্যাটেরিয়াল ডিজাইন ওয়েবসাইটে ফন্ট সাইজ ইউনিটস দেখুন।
    ব্যবধান স্বাভাবিক

উদাহরণ CSS

নিম্নলিখিত CSS কোডটি একটি সাদা বা হালকা ব্যাকগ্রাউন্ডে উপযুক্ত টাইপোগ্রাফিক স্টাইল এবং রঙ সহ Google Maps লেখাটি রেন্ডার করে।

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

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

প্রসঙ্গ টোকেন এবং স্থান আইডির ক্যাশিং

Google Maps গ্রাউন্ডেড রেজাল্টে কনটেক্সট টোকেন এবং প্লেস আইডি অন্তর্ভুক্ত থাকতে পারে। আপনি নিম্নলিখিত রেসপন্স ডেটা ক্যাশ, স্টোর এবং এক্সপোর্ট করতে পারেন:

  • (শুধুমাত্র ওয়েব এসডিকে-এর জন্য) googleMapsWidgetContextToken
  • placeId

‘গ্রাউন্ডিং উইথ গুগল ম্যাপস’-এর শর্তাবলীতে থাকা ক্যাশিং-এর উপর নিষেধাজ্ঞা এই ডেটার ক্ষেত্রে প্রযোজ্য নয়।

নিষিদ্ধ কার্যকলাপ এবং অঞ্চল

একটি নিরাপদ এবং নির্ভরযোগ্য প্ল্যাটফর্ম বজায় রাখার জন্য, গ্রাউন্ডিং উইথ Google Maps নির্দিষ্ট কিছু কন্টেন্ট এবং কার্যকলাপের উপর অতিরিক্ত বিধিনিষেধ রয়েছে। আপনার নির্বাচিত জেমিনি এপিআই প্রদানকারী: জেমিনি ডেভেলপার এপিআই বা এজেন্ট প্ল্যাটফর্ম জেমিনি এপিআই (পূর্বে ভার্টেক্স এআই) -এর ব্যবহারের বিধিনিষেধ ছাড়াও, শর্তাবলীতে এই বিধিনিষেধগুলো প্রযোজ্য (পরিষেবা-নির্দিষ্ট শর্তাবলীর মধ্যে পরিষেবা শর্তাবলী বিভাগটি দেখুন)।

  • আপনি জরুরি প্রতিক্রিয়া পরিষেবা সহ উচ্চ ঝুঁকিপূর্ণ কার্যকলাপের জন্য Google Maps সাথে গ্রাউন্ডিং ব্যবহার করবেন না।

  • আপনি কোনো নিষিদ্ধ অঞ্চলে Google Maps এর গ্রাউন্ডিং পরিষেবা প্রদানকারী আপনার অ্যাপ্লিকেশনটি বিতরণ বা বাজারজাত করবেন না। আরও তথ্যের জন্য, গুগল ম্যাপস প্ল্যাটফর্মের নিষিদ্ধ অঞ্চলসমূহ দেখুন। নিষিদ্ধ অঞ্চলসমূহের তালিকা সময়ে সময়ে হালনাগাদ করা হতে পারে।

Firebase কনসোলে বাস্তব ফলাফল এবং এআই পর্যবেক্ষণ

আপনি যদি Firebase কনসোলে AI মনিটরিং চালু করে থাকেন, তাহলে প্রাপ্ত প্রতিক্রিয়াগুলো Cloud Logging -এ সংরক্ষিত হয়। ডিফল্টরূপে, এই ডেটা ৩০ দিনের জন্য সংরক্ষিত থাকে।

এই ডেটা সংরক্ষণের সময়কাল, অথবা আপনার সেট করা যেকোনো কাস্টম সময়কাল, যেন আপনার নির্দিষ্ট ব্যবহারের ক্ষেত্র এবং আপনার নির্বাচিত Gemini API প্রদানকারী— Gemini Developer API বা Agent Platform Gemini API (পূর্বে Vertex AI)— এর জন্য প্রযোজ্য যেকোনো অতিরিক্ত কমপ্লায়েন্স প্রয়োজনীয়তার সাথে সম্পূর্ণরূপে সামঞ্জস্যপূর্ণ হয়, তা নিশ্চিত করা আপনার দায়িত্ব (পরিষেবা-নির্দিষ্ট শর্তাবলীর মধ্যে পরিষেবা শর্তাবলী বিভাগটি দেখুন)। এই প্রয়োজনীয়তাগুলো পূরণের জন্য আপনাকে ক্লাউড লগিং-এ ডেটা সংরক্ষণের সময়কাল সমন্বয় করতে হতে পারে।

মূল্য নির্ধারণ এবং হারের সীমা

Google Maps গ্রাউন্ডিং-এর মূল্য কোয়েরির উপর ভিত্তি করে নির্ধারিত হয়। একটি অনুরোধ তখনই Google Maps কোটার আওতায় গণনা করা হয়, যখন একটি প্রম্পট সফলভাবে অন্তত একটি Google Maps গ্রাউন্ডেড রেজাল্ট প্রদান করে (অর্থাৎ, রেসপন্সটিতে অন্তত একটি Google Maps সোর্স থাকে)। যদি একটিমাত্র অনুরোধ থেকে Google Maps এ একাধিক কোয়েরি পাঠানো হয়, তবে তা রেট লিমিটের জন্য একটি অনুরোধ হিসেবে গণ্য হবে।

আপনার নির্বাচিত Gemini API প্রদানকারীর ডকুমেন্টেশনে ( Gemini Developer API |Agent Platform Gemini API (পূর্বের Vertex AI)) Grounding with Google Maps মূল্য, মডেলের প্রাপ্যতা এবং সীমাবদ্ধতা সম্পর্কে বিস্তারিত তথ্য পর্যালোচনা করে নিন।

,

গ্রাউন্ডিং উইথ Google Maps একটি জেমিনি মডেলকে Google Maps -এর ভূ-স্থানিক ডেটার সাথে সংযুক্ত করে, যাতে আপনি আপনার অ্যাপগুলিতে অবস্থান-সচেতন কার্যকারিতা যুক্ত করতে পারেন।

Google Maps ব্যবহারের নিম্নলিখিত সুবিধাগুলো রয়েছে:

  • তথ্যগত নির্ভুলতা বৃদ্ধি করুন : গুগলের ২৫ কোটিরও বেশি বাস্তব স্থান ও ব্যবসার ডেটাবেসের উপর ভিত্তি করে প্রতিক্রিয়া তৈরি করে মডেলের বিভ্রম হ্রাস করুন।
  • রিয়েল-টাইম তথ্য অ্যাক্সেস করুন : লাইভ ডেটা ব্যবহার করে প্রশ্নের উত্তর দিন, যেমন বর্তমান ব্যবসায়িক সময় এবং ইভি চার্জিং স্টেশনগুলির রিয়েল-টাইম স্ট্যাটাস।
  • দৃশ্যমান প্রেক্ষাপট প্রদান করুন : মডেলের অবস্থান-ভিত্তিক দাবির পাশাপাশি সরাসরি ইন্টারেক্টিভ ম্যাপ উইজেট, ছবি এবং স্ট্রিট ভিউ যুক্ত করে ব্যবহারকারীর আস্থা তৈরি করুন।

সমর্থিত মডেল

  • gemini-3.1-pro-preview
  • gemini-3.6-flash (এবং পুরোনো gemini-3.5-flash )
  • gemini-3.5-flash-lite (এবং পুরোনো gemini-3.1-flash-lite )

সাধারণ ব্যবহারের জেমিনি ২.৫ মডেলগুলিতে এই সক্ষমতা ছিল, কিন্তু সেগুলি এখন আর ব্যবহৃত হয় না।

সমর্থিত ভাষা

জেমিনি মডেলগুলির জন্য সমর্থিত ভাষাগুলি দেখুন।

Google Maps দিয়ে মডেলটিকে ভিত্তি দিন।

এই পৃষ্ঠায় প্রদানকারী-নির্দিষ্ট বিষয়বস্তু এবং কোড দেখতে আপনার জেমিনি এপিআই প্রদানকারীর উপর ক্লিক করুন।

যখন আপনি GenerativeModel ইনস্ট্যান্সটি তৈরি করবেন, তখন মডেলটির প্রতিক্রিয়া তৈরি করার জন্য একটি tool হিসেবে GoogleMaps প্রদান করুন।

সুইফট


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

ঐক্য


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

কীভাবে একটি মডেল বেছে নিতে হয় তা জানুনআপনার ব্যবহারের ক্ষেত্র এবং অ্যাপের জন্য উপযুক্ত।

ফলাফল উন্নত করার সেরা উপায় ও পরামর্শ

এই বিভাগে Google Maps সাথে গ্রাউন্ডিং ব্যবহারের কিছু সাধারণ সেরা অনুশীলন এবং ফলাফল উন্নত করার জন্য স্থানের বৈশিষ্ট্যগুলো কীভাবে কাজে লাগানো যায়, তা বর্ণনা করা হয়েছে।

সাধারণ সর্বোত্তম অনুশীলন

  • শুধুমাত্র প্রয়োজনের সময় টুলটি সরবরাহ করুন : কর্মক্ষমতা এবং খরচ অপ্টিমাইজ করতে, মডেলটিকে 'গ্রাউন্ডিং উইথ Google Maps টুলটিতে অ্যাক্সেস কেবল তখনই দিন যখন ব্যবহারের ক্ষেত্রটির একটি স্পষ্ট ভৌগোলিক প্রেক্ষাপট থাকে।

  • ব্যবহারকারীর অবস্থান প্রদান করুন : সবচেয়ে প্রাসঙ্গিক এবং ব্যক্তিগতকৃত প্রতিক্রিয়ার জন্য (এবং যখন ব্যবহারকারীর অবস্থান জানা থাকে), ‘গ্রাউন্ডিং উইথ Google Maps টুলের কনফিগারেশনে ব্যবহারকারীর অবস্থান ( latLng এর মাধ্যমে অক্ষাংশ এবং দ্রাঘিমাংশ ব্যবহার করে) অন্তর্ভুক্ত করুন।

  • ব্যবহারকারীদের অবহিত করুন : আপনার ব্যবহারকারীদের স্পষ্টভাবে জানান যে তাদের জিজ্ঞাসার উত্তর দিতে Google Maps ডেটা ব্যবহার করা হচ্ছে। ‘গ্রাউন্ডিং উইথ Google Maps টুলটির জন্য ব্যবহারকারীদের কাছে Google Maps থেকে ডেটার উৎস সরবরাহ করা একটি আবশ্যিক পরিষেবা

  • (শুধুমাত্র ওয়েব SDK-এর জন্য) Google Maps কনটেক্সচুয়াল উইজেট রেন্ডার করুন : কনটেক্সচুয়াল উইজেটটি কনটেক্সট টোকেন, googleMapsWidgetContextToken , ব্যবহার করে রেন্ডার করা হয়, যা জেমিনি এপিআই রেসপন্সে ফেরত আসে এবং Google Maps থেকে ভিজ্যুয়াল কন্টেন্ট রেন্ডার করতে ব্যবহার করা যায়। কনটেক্সচুয়াল উইজেট সম্পর্কে আরও তথ্যের জন্য, Google Maps ডকুমেন্টেশনে "গ্রাউন্ডিং উইথ Google Maps উইজেট" দেখুন।

প্রম্পটে স্থানের বৈশিষ্ট্য ব্যবহার করুন

এই বিভাগে স্থানের সেই বৈশিষ্ট্যগুলো তালিকাভুক্ত করা হয়েছে, যেগুলো অবস্থান বর্ণনা করতে এবং ‘গ্রাউন্ডিং উইথ Google Maps দ্বারা প্রতিক্রিয়া তৈরি করতে ব্যবহৃত হয়। এই বৈশিষ্ট্যগুলো ‘গ্রাউন্ডিং উইথ Google Maps কোন ধরনের প্রশ্নের উত্তর দিতে পারবে, তা নির্ধারণ করতে ব্যবহৃত হয়।

নমুনা স্থানের বৈশিষ্ট্য

এই তালিকাটি স্থান সম্পর্কিত এমন কিছু বৈশিষ্ট্যের বর্ণানুক্রমিক নমুনা প্রদান করে, যা আপনার মডেল প্রতিক্রিয়া তৈরি করতে ব্যবহার করতে পারে।

  • ঠিকানা
  • কার্বসাইড পিকআপ
  • ডেবিট কার্ড
  • দূরত্ব
  • বিনামূল্যে পার্কিং লট
  • লাইভ সঙ্গীত
  • শিশুদের জন্য মেনু
  • খোলার সময়
  • অর্থপ্রদানের বিকল্প (যেমন নগদ বা ক্রেডিট কার্ড )
  • উত্তর দিন
  • পোষা প্রাণীবান্ধব
  • বিয়ার পরিবেশন করে
  • নিরামিষ খাবার পরিবেশন করা হয়
  • হুইলচেয়ার প্রবেশযোগ্য
  • ওয়াইফাই

প্লেস অ্যানসারস হলো গ্রাউন্ডিং উইথ Google Maps পক্ষ থেকে ব্যবহারকারীদের রিভিউ থেকে প্রাপ্ত তথ্যের উপর ভিত্তি করে দেওয়া একটি প্রতিক্রিয়া।

স্থান বৈশিষ্ট্য ব্যবহার করে এমন উদাহরণ প্রম্পট।

নিম্নলিখিত উদাহরণগুলিতে বিভিন্ন ধরণের স্থান সম্পর্কিত নির্দেশনায় স্থানের বৈশিষ্ট্য ব্যবহার করা হয়েছে। গ্রাউন্ডিং উইথ Google Maps আপনার উদ্দেশ্য বোঝার জন্য এই বৈশিষ্ট্যগুলি ব্যবহার করে এবং তারপরে Google Maps এর স্থানগুলির সাথে সম্পর্কিত ডেটার উপর ভিত্তি করে প্রাসঙ্গিক উত্তর প্রদান করে।

  • পারিবারিক নৈশভোজের পরিকল্পনা করুন : রেস্তোরাঁটি পরিবারের জন্য উপযুক্ত কিনা এবং সেখানে সুবিধাজনক পরিষেবা দেওয়া হয় কিনা তা যাচাই করুন।

    • উদাহরণস্বরূপ প্রশ্ন: "দ্য ইতালিয়ান প্লেস" কি বাচ্চাদের জন্য ভালো, এবং তারা কি টেকআউট পরিষেবা দেয়? তাদের রেটিং কত?
  • বন্ধুর জন্য প্রবেশগম্যতা যাচাই করুন : স্থানটি নির্দিষ্ট প্রবেশগম্যতার চাহিদা পূরণ করে কিনা তা নির্ধারণ করুন।

    • উদাহরণস্বরূপ জিজ্ঞাসা: আমার এমন একটি রেস্তোরাঁ প্রয়োজন যার প্রবেশপথ হুইলচেয়ার ব্যবহারকারীদের জন্য প্রবেশযোগ্য।
  • গভীর রাতের নাস্তার জন্য একটি জায়গা খুঁজুন : এমন একটি খোলা প্রতিষ্ঠান খুঁজুন যেখানে একটি নির্দিষ্ট সময়ে একটি নির্দিষ্ট খাবার পরিবেশন করা হয়।

    • উদাহরণস্বরূপ প্রশ্ন: "বার্গার জয়েন্ট" কি এখন খোলা আছে? ওরা কি রাতের খাবার পরিবেশন করে? শুক্রবারে ওদের খোলার সময়সূচী কী?
  • ক্লায়েন্টের সাথে কফি খেতে সাক্ষাৎ : সুযোগ-সুবিধা, প্রদত্ত পরিষেবা এবং অর্থ পরিশোধের পদ্ধতির উপর ভিত্তি করে একটি ব্যবসায়িক বৈঠকের জন্য ক্যাফেটির উপযুক্ততা মূল্যায়ন করুন।

    • উদাহরণস্বরূপ প্রশ্ন: "ক্যাফে সেন্ট্রাল"-এ কি ওয়াইফাই আছে? তারা কি কফি পরিবেশন করে? তাদের মূল্যস্তর কেমন, এবং তারা কি ক্রেডিট কার্ড গ্রহণ করে?

মনে রাখবেন যে, Google Maps বাস্তব ফলাফলের তথ্য রাস্তার প্রকৃত অবস্থা থেকে ভিন্ন হতে পারে।

Google Maps দিয়ে গ্রাউন্ডিং কীভাবে কাজ করে

যখন আপনি মডেলটিকে GoogleMaps টুলটি প্রদান করেন, তখন মডেলটি স্বয়ংক্রিয়ভাবে তথ্য অনুসন্ধান, প্রক্রিয়াকরণ এবং উদ্ধৃতি দেওয়ার সম্পূর্ণ কার্যপ্রবাহটি পরিচালনা করে।

মডেলটির কার্যপ্রবাহ নিচে দেওয়া হলো:

  1. প্রম্পট গ্রহণ করে : আপনার অ্যাপটি GoogleMaps টুল সক্রিয় থাকা জেমিনি মডেলে একটি প্রম্পট পাঠায়।

  2. প্রম্পট বিশ্লেষণ করে : মডেলটি প্রম্পটটি বিশ্লেষণ করে এবং নির্ধারণ করে যে Google Maps তার প্রতিক্রিয়া উন্নত করতে পারে কিনা, উদাহরণস্বরূপ, যদি প্রম্পটটিতে ভৌগোলিক প্রসঙ্গ থাকে (যেমন "আমার কাছাকাছি কফি শপ," "সান ফ্রান্সিসকোর জাদুঘর")।

  3. টুলটি চালু করে : মডেলটি ভৌগোলিক অভিপ্রায় শনাক্ত করে ‘গ্রাউন্ডিং উইথ Google Maps টুলটি চালু করে।

  4. Google Maps এ অনুসন্ধান পাঠায় : ‘গ্রাউন্ডিং উইথ Google Maps পরিষেবাটি প্রাসঙ্গিক তথ্যের (যেমন, স্থান, পর্যালোচনা, ছবি, ঠিকানা, খোলার সময়) জন্য Google Maps অনুসন্ধান করে।

    আরও প্রাসঙ্গিক এবং ব্যক্তিগতকৃত Google Maps ফলাফল পেতে, আপনি ঐচ্ছিকভাবে টুলটির কনফিগে (অথবা সরাসরি প্রম্পটেও) অক্ষাংশ এবং দ্রাঘিমাংশ অন্তর্ভুক্ত করতে পারেন। টুলটি একটি টেক্সচুয়াল সার্চ টুল এবং এটি Google Maps সার্চ করার মতোই কাজ করে; অর্থাৎ, স্থানীয় অনুসন্ধানের ("আমার কাছাকাছি") ক্ষেত্রে স্থানাঙ্ক ব্যবহার করা হয়, কিন্তু নির্দিষ্ট বা অস্থানীয় অনুসন্ধানের ক্ষেত্রে সুস্পষ্ট অবস্থান দ্বারা প্রভাবিত হওয়ার সম্ভাবনা কম।

  5. Google Maps ফলাফল প্রক্রিয়াকরণ : মডেলটি Google Maps ফলাফল প্রক্রিয়াকরণ করে এবং মূল নির্দেশনার একটি প্রতিক্রিয়া তৈরি করে।

  6. Google Maps -ভিত্তিক ফলাফল প্রদান করে : মডেলটি একটি চূড়ান্ত, ব্যবহারকারী-বান্ধব প্রতিক্রিয়া প্রদান করে যা Google Maps ফলাফলের উপর ভিত্তি করে তৈরি। এই প্রতিক্রিয়ায় অন্তর্ভুক্ত থাকে:

    • মডেলের টেক্সট উত্তর।
    • একটি groundingMetadata অবজেক্ট, যাতে Google Maps ফলাফল এবং উৎসগুলো রয়েছে।
    • (শুধুমাত্র ওয়েব এসডিকে-এর জন্য) ঐচ্ছিকভাবে একটি googleMapsWidgetContextToken, যা আপনাকে ভিজ্যুয়াল ইন্টারঅ্যাকশনের জন্য আপনার অ্যাপে একটি প্রাসঙ্গিক Google Maps উইজেট রেন্ডার করতে দেয়। প্রাসঙ্গিক উইজেট সম্পর্কে আরও তথ্যের জন্য, Google Maps ডকুমেন্টেশনে "গ্রাউন্ডিং উইথ Google Maps উইজেট" দেখুন।

উল্লেখ্য যে, মডেলে একটি টুল হিসেবে Google Maps প্রদান করার অর্থ এই নয় যে, মডেলটিকে তার প্রতিক্রিয়া তৈরি করার জন্য সর্বদা Google Maps টুলটিই ব্যবহার করতে হবে। এই ক্ষেত্রে, প্রতিক্রিয়াটিতে কোনো groundingMetadata অবজেক্ট থাকবে না এবং তাই এটি একটি Google Maps গ্রাউন্ডেড রেজাল্ট নয়

বাস্তব ফলাফলটি বুঝুন

যদি মডেলটি Google Maps ফলাফলের উপর ভিত্তি করে তার প্রতিক্রিয়া তৈরি করে, তাহলে সেই প্রতিক্রিয়ায় একটি groundingMetadata অবজেক্ট অন্তর্ভুক্ত থাকে। এই অবজেক্টটিতে এমন কাঠামোগত ডেটা থাকে যা দাবি যাচাই করার জন্য এবং আপনার অ্যাপ্লিকেশনে একটি সমৃদ্ধ উৎস অভিজ্ঞতা তৈরি করার জন্য অপরিহার্য।

Google Maps গ্রাউন্ডেড রেজাল্টের মধ্যে থাকা groundingMetadata অবজেক্টটিতে নিম্নলিখিত তথ্য থাকে:

  • groundingChunks : অবজেক্টের একটি অ্যারে, যেখানে maps উৎসগুলো ( uri , placeId , এবং title ) থাকে।
  • groundingSupports : মডেল রেসপন্স text groundingChunks এর সোর্সগুলোর সাথে সংযুক্ত করার জন্য চাঙ্কগুলোর একটি অ্যারে। প্রতিটি চাঙ্ক একটি টেক্সট segment (যা startIndex এবং endIndex দ্বারা সংজ্ঞায়িত) এক বা একাধিক groundingChunkIndices এর সাথে লিঙ্ক করে। এই ফিল্ডটি আপনাকে ইনলাইন সোর্স লিঙ্ক তৈরি করতে সাহায্য করে। এই পৃষ্ঠার পরবর্তী অংশে জানুন কীভাবে সার্ভিস ব্যবহারের প্রয়োজনীয়তাগুলো পূরণ করতে হয়।
  • (শুধুমাত্র ওয়েব এসডিকে-এর জন্য) googleMapsWidgetContextToken : একটি টেক্সট টোকেন যা একটি প্রাসঙ্গিক প্লেসেস উইজেট রেন্ডার করতে ব্যবহার করা যেতে পারে। এই ফিল্ডটি শুধুমাত্র ওয়েব এসডিকে ব্যবহার করার সময় এবং যদি আপনি enableWidget প্যারামিটারটি true সেট করে থাকেন, তবেই ফেরত আসে।

এখানে একটি উদাহরণ প্রতিক্রিয়া দেওয়া হল, যাতে একটি groundingMetadata অবজেক্ট অন্তর্ভুক্ত রয়েছে:

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

পরিষেবা ব্যবহারের প্রয়োজনীয়তা

এই বিভাগে আপনার নির্বাচিত Gemini API প্রদানকারী— Gemini Developer API অথবা Agent Platform Gemini API (পূর্বে Vertex AI)— এর জন্য Grounding with Google Maps এর পরিষেবা ব্যবহারের প্রয়োজনীয়তা বর্ণনা করা হয়েছে (পরিষেবা নির্দিষ্ট শর্তাবলীর মধ্যে পরিষেবা শর্তাবলী বিভাগটি দেখুন)।

Google Maps ব্যবহারকারীদের উৎস সম্পর্কে অবহিত করুন।

প্রতিটি Google Maps গ্রাউন্ডেড রেজাল্ট-এর সাথে, আপনি groundingChunks এ সেই সোর্সগুলো পাবেন যা প্রতিটি রেসপন্সকে সাপোর্ট করে। এছাড়াও নিম্নলিখিত মেটাডেটা ফেরত দেওয়া হয়:

  • উৎস ইউআরআই
  • শিরোনাম
  • আইডি

আপনার অ্যাপে, ‘গ্রাউন্ডিং উইথ Google Maps থেকে প্রাপ্ত ফলাফল দেখানোর সময়, আপনাকে অবশ্যই সংশ্লিষ্ট Google Maps উৎসগুলো উল্লেখ করতে হবে এবং আপনার ব্যবহারকারীদের নিম্নলিখিত বিষয়গুলো সম্পর্কে জানাতে হবে:

  • Google Maps সোর্সগুলোকে অবশ্যই সেই সোর্স-সমর্থিত জেনারেটেড কন্টেন্টের ঠিক পরেই থাকতে হবে। এই জেনারেটেড কন্টেন্টকে Google Maps গ্রাউন্ডেড রেজাল্ট নামেও উল্লেখ করা হয়।

  • Google Maps উৎসগুলো অবশ্যই একটিমাত্র ব্যবহারকারী ইন্টারঅ্যাকশনের মধ্যেই দেখার যোগ্য হতে হবে।

Google Maps গ্রাউন্ডেড রেজাল্ট থেকে সোর্স প্রদর্শনের জন্য ভ্যালুগুলো যেভাবে পাবেন, তা নিচে দেওয়া হলো:

সুইফট

// ...

// 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
  }
}

ঐক্য

// ...

// 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 কে দিন।
  • প্রতিক্রিয়ায় প্রদত্ত উৎসের শিরোনামটি প্রদর্শন করুন।
  • রেসপন্স থেকে প্রাপ্ত uri ব্যবহার করে সোর্সের সাথে লিঙ্ক করুন।

উৎস দেখানো সহ প্রতিক্রিয়া জানান।

আপনি উৎসগুলোর দৃশ্য সংকুচিত করতে পারেন।

প্রতিক্রিয়া এবং উৎস সহ প্রম্পটটি ভেঙে গেছে

ঐচ্ছিকভাবে, আপনি অতিরিক্ত বিষয়বস্তু দিয়ে লিঙ্ক প্রিভিউটিকে আরও উন্নত করতে পারেন, যেমন:

  • Google Maps টেক্সট অ্যাট্রিবিউশনের আগে একটি Google Maps ফেভিকন যুক্ত করা হয়েছে।
  • উৎস ইউআরএল ( og:image ) থেকে প্রাপ্ত একটি ছবি।

Google Maps এর কিছু ডেটা সরবরাহকারী এবং তাদের লাইসেন্সের শর্তাবলী সম্পর্কে আরও তথ্যের জন্য, গুগল ম্যাপস ও গুগল আর্থ-এর আইনি বিজ্ঞপ্তিগুলো দেখুন।

Google Maps টেক্সট অ্যাট্রিবিউশন নির্দেশিকা

লেখার মধ্যে Google Maps এর উৎস উল্লেখ করার সময় এই নির্দেশিকাগুলো অনুসরণ করুন:

  • Google Maps লেখাটি কোনোভাবেই পরিবর্তন করবেন না:

    • Google Maps লেখাটির বড় হাতের অক্ষরের ব্যবহার পরিবর্তন করবেন না।
    • Google Maps লেখাটি একাধিক লাইনে রাখবেন না।
    • Google Maps লেখাটি অন্য কোনো ভাষায় স্থানীয়করণ করবেন না।
    • HTML অ্যাট্রিবিউট translate="no" ব্যবহার করে ব্রাউজারকে Google Maps লেখাটির অনুবাদ করা থেকে বিরত রাখুন।
  • নিম্নলিখিত সারণিতে বর্ণিত পদ্ধতি অনুসারে Google Maps টেক্সটটি স্টাইল করুন:

    সম্পত্তি শৈলী
    ফন্ট পরিবার রোবোটো। ফন্টটি লোড করা ঐচ্ছিক।
    ফলব্যাক ফন্ট পরিবার আপনার পণ্যে ইতিমধ্যে ব্যবহৃত যেকোনো স্যান্স সেরিফ বডি ফন্ট অথবা ডিফল্ট সিস্টেম ফন্ট চালু করার জন্য "Sans-Serif" ব্যবহার করুন।
    ফন্ট শৈলী স্বাভাবিক
    ফন্টের ওজন ৪০০
    ফন্টের রঙ সাদা, কালো (#1F1F1F), অথবা ধূসর (#5E5E5E)। পটভূমির সাথে সুলভ (৪.৫:১) বৈসাদৃশ্য বজায় রাখুন।
    ফন্টের আকার সর্বনিম্ন ফন্ট সাইজ: ১২sp
    সর্বোচ্চ ফন্ট সাইজ: ১৬sp
    sp সম্পর্কে জানতে, ম্যাটেরিয়াল ডিজাইন ওয়েবসাইটে ফন্ট সাইজ ইউনিটস দেখুন।
    ব্যবধান স্বাভাবিক

উদাহরণ CSS

নিম্নলিখিত CSS কোডটি একটি সাদা বা হালকা ব্যাকগ্রাউন্ডে উপযুক্ত টাইপোগ্রাফিক স্টাইল এবং রঙ সহ Google Maps লেখাটি রেন্ডার করে।

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

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

প্রসঙ্গ টোকেন এবং স্থান আইডির ক্যাশিং

Google Maps গ্রাউন্ডেড রেজাল্টে কনটেক্সট টোকেন এবং প্লেস আইডি অন্তর্ভুক্ত থাকতে পারে। আপনি নিম্নলিখিত রেসপন্স ডেটা ক্যাশ, স্টোর এবং এক্সপোর্ট করতে পারেন:

  • (শুধুমাত্র ওয়েব এসডিকে-এর জন্য) googleMapsWidgetContextToken
  • placeId

‘গ্রাউন্ডিং উইথ গুগল ম্যাপস’-এর শর্তাবলীতে থাকা ক্যাশিং-এর উপর নিষেধাজ্ঞা এই ডেটার ক্ষেত্রে প্রযোজ্য নয়।

নিষিদ্ধ কার্যকলাপ এবং অঞ্চল

একটি নিরাপদ এবং নির্ভরযোগ্য প্ল্যাটফর্ম বজায় রাখার জন্য, গ্রাউন্ডিং উইথ Google Maps নির্দিষ্ট কিছু কন্টেন্ট এবং কার্যকলাপের উপর অতিরিক্ত বিধিনিষেধ রয়েছে। আপনার নির্বাচিত জেমিনি এপিআই প্রদানকারী: জেমিনি ডেভেলপার এপিআই বা এজেন্ট প্ল্যাটফর্ম জেমিনি এপিআই (পূর্বে ভার্টেক্স এআই) -এর ব্যবহারের বিধিনিষেধ ছাড়াও, শর্তাবলীতে এই বিধিনিষেধগুলো প্রযোজ্য (পরিষেবা-নির্দিষ্ট শর্তাবলীর মধ্যে পরিষেবা শর্তাবলী বিভাগটি দেখুন)।

  • আপনি জরুরি প্রতিক্রিয়া পরিষেবা সহ উচ্চ ঝুঁকিপূর্ণ কার্যকলাপের জন্য Google Maps সাথে গ্রাউন্ডিং ব্যবহার করবেন না।

  • আপনি কোনো নিষিদ্ধ অঞ্চলে Google Maps এর গ্রাউন্ডিং পরিষেবা প্রদানকারী আপনার অ্যাপ্লিকেশনটি বিতরণ বা বাজারজাত করবেন না। আরও তথ্যের জন্য, গুগল ম্যাপস প্ল্যাটফর্মের নিষিদ্ধ অঞ্চলসমূহ দেখুন। নিষিদ্ধ অঞ্চলসমূহের তালিকা সময়ে সময়ে হালনাগাদ করা হতে পারে।

Firebase কনসোলে বাস্তব ফলাফল এবং এআই পর্যবেক্ষণ

আপনি যদি Firebase কনসোলে AI মনিটরিং চালু করে থাকেন, তাহলে প্রাপ্ত প্রতিক্রিয়াগুলো Cloud Logging -এ সংরক্ষিত হয়। ডিফল্টরূপে, এই ডেটা ৩০ দিনের জন্য সংরক্ষিত থাকে।

এই ডেটা সংরক্ষণের সময়কাল, অথবা আপনার সেট করা যেকোনো কাস্টম সময়কাল, যেন আপনার নির্দিষ্ট ব্যবহারের ক্ষেত্র এবং আপনার নির্বাচিত Gemini API প্রদানকারী— Gemini Developer API বা Agent Platform Gemini API (পূর্বে Vertex AI)— এর জন্য প্রযোজ্য যেকোনো অতিরিক্ত কমপ্লায়েন্স প্রয়োজনীয়তার সাথে সম্পূর্ণরূপে সামঞ্জস্যপূর্ণ হয়, তা নিশ্চিত করা আপনার দায়িত্ব (পরিষেবা-নির্দিষ্ট শর্তাবলীর মধ্যে পরিষেবা শর্তাবলী বিভাগটি দেখুন)। এই প্রয়োজনীয়তাগুলো পূরণের জন্য আপনাকে ক্লাউড লগিং-এ ডেটা সংরক্ষণের সময়কাল সমন্বয় করতে হতে পারে।

মূল্য নির্ধারণ এবং হারের সীমা

Google Maps গ্রাউন্ডিং-এর মূল্য কোয়েরির উপর ভিত্তি করে নির্ধারিত হয়। একটি অনুরোধ তখনই Google Maps কোটার আওতায় গণনা করা হয়, যখন একটি প্রম্পট সফলভাবে অন্তত একটি Google Maps গ্রাউন্ডেড রেজাল্ট প্রদান করে (অর্থাৎ, রেসপন্সটিতে অন্তত একটি Google Maps সোর্স থাকে)। যদি একটিমাত্র অনুরোধ থেকে Google Maps এ একাধিক কোয়েরি পাঠানো হয়, তবে তা রেট লিমিটের জন্য একটি অনুরোধ হিসেবে গণ্য হবে।

আপনার নির্বাচিত Gemini API প্রদানকারীর ডকুমেন্টেশনে ( Gemini Developer API |Agent Platform Gemini API (পূর্বের Vertex AI)) Grounding with Google Maps মূল্য, মডেলের প্রাপ্যতা এবং সীমাবদ্ধতা সম্পর্কে বিস্তারিত তথ্য পর্যালোচনা করে নিন।

,

গ্রাউন্ডিং উইথ Google Maps একটি জেমিনি মডেলকে Google Maps -এর ভূ-স্থানিক ডেটার সাথে সংযুক্ত করে, যাতে আপনি আপনার অ্যাপগুলিতে অবস্থান-সচেতন কার্যকারিতা যুক্ত করতে পারেন।

Google Maps ব্যবহারের নিম্নলিখিত সুবিধাগুলো রয়েছে:

  • তথ্যগত নির্ভুলতা বৃদ্ধি করুন : গুগলের ২৫ কোটিরও বেশি বাস্তব স্থান ও ব্যবসার ডেটাবেসের উপর ভিত্তি করে প্রতিক্রিয়া তৈরি করে মডেলের বিভ্রম হ্রাস করুন।
  • রিয়েল-টাইম তথ্য অ্যাক্সেস করুন : লাইভ ডেটা ব্যবহার করে প্রশ্নের উত্তর দিন, যেমন বর্তমান ব্যবসায়িক সময় এবং ইভি চার্জিং স্টেশনগুলির রিয়েল-টাইম স্ট্যাটাস।
  • দৃশ্যমান প্রেক্ষাপট প্রদান করুন : মডেলের অবস্থান-ভিত্তিক দাবির পাশাপাশি সরাসরি ইন্টারেক্টিভ ম্যাপ উইজেট, ছবি এবং স্ট্রিট ভিউ যুক্ত করে ব্যবহারকারীর আস্থা তৈরি করুন।

সমর্থিত মডেল

  • gemini-3.1-pro-preview
  • gemini-3.6-flash (এবং পুরোনো gemini-3.5-flash )
  • gemini-3.5-flash-lite (এবং পুরোনো gemini-3.1-flash-lite )

সাধারণ ব্যবহারের জেমিনি ২.৫ মডেলগুলিতে এই সক্ষমতা ছিল, কিন্তু সেগুলি এখন আর ব্যবহৃত হয় না।

সমর্থিত ভাষা

জেমিনি মডেলগুলির জন্য সমর্থিত ভাষাগুলি দেখুন।

Google Maps দিয়ে মডেলটিকে ভিত্তি দিন।

এই পৃষ্ঠায় প্রদানকারী-নির্দিষ্ট বিষয়বস্তু এবং কোড দেখতে আপনার জেমিনি এপিআই প্রদানকারীর উপর ক্লিক করুন।

যখন আপনি GenerativeModel ইনস্ট্যান্সটি তৈরি করবেন, তখন মডেলটির প্রতিক্রিয়া তৈরি করার জন্য একটি tool হিসেবে GoogleMaps প্রদান করুন।

সুইফট


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

ঐক্য


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

কীভাবে একটি মডেল বেছে নিতে হয় তা জানুনআপনার ব্যবহারের ক্ষেত্র এবং অ্যাপের জন্য উপযুক্ত।

ফলাফল উন্নত করার সেরা উপায় ও পরামর্শ

এই বিভাগে Google Maps সাথে গ্রাউন্ডিং ব্যবহারের কিছু সাধারণ সেরা অনুশীলন এবং ফলাফল উন্নত করার জন্য স্থানের বৈশিষ্ট্যগুলো কীভাবে কাজে লাগানো যায়, তা বর্ণনা করা হয়েছে।

সাধারণ সর্বোত্তম অনুশীলন

  • শুধুমাত্র প্রয়োজনের সময় টুলটি সরবরাহ করুন : কর্মক্ষমতা এবং খরচ অপ্টিমাইজ করতে, মডেলটিকে 'গ্রাউন্ডিং উইথ Google Maps টুলটিতে অ্যাক্সেস কেবল তখনই দিন যখন ব্যবহারের ক্ষেত্রটির একটি স্পষ্ট ভৌগোলিক প্রেক্ষাপট থাকে।

  • ব্যবহারকারীর অবস্থান প্রদান করুন : সবচেয়ে প্রাসঙ্গিক এবং ব্যক্তিগতকৃত প্রতিক্রিয়ার জন্য (এবং যখন ব্যবহারকারীর অবস্থান জানা থাকে), ‘গ্রাউন্ডিং উইথ Google Maps টুলের কনফিগারেশনে ব্যবহারকারীর অবস্থান ( latLng এর মাধ্যমে অক্ষাংশ এবং দ্রাঘিমাংশ ব্যবহার করে) অন্তর্ভুক্ত করুন।

  • ব্যবহারকারীদের অবহিত করুন : আপনার ব্যবহারকারীদের স্পষ্টভাবে জানান যে তাদের জিজ্ঞাসার উত্তর দিতে Google Maps ডেটা ব্যবহার করা হচ্ছে। ‘গ্রাউন্ডিং উইথ Google Maps টুলটির জন্য ব্যবহারকারীদের কাছে Google Maps থেকে ডেটার উৎস সরবরাহ করা একটি আবশ্যিক পরিষেবা

  • (শুধুমাত্র ওয়েব SDK-এর জন্য) Google Maps কনটেক্সচুয়াল উইজেট রেন্ডার করুন : কনটেক্সচুয়াল উইজেটটি কনটেক্সট টোকেন, googleMapsWidgetContextToken , ব্যবহার করে রেন্ডার করা হয়, যা জেমিনি এপিআই রেসপন্সে ফেরত আসে এবং Google Maps থেকে ভিজ্যুয়াল কন্টেন্ট রেন্ডার করতে ব্যবহার করা যায়। কনটেক্সচুয়াল উইজেট সম্পর্কে আরও তথ্যের জন্য, Google Maps ডকুমেন্টেশনে "গ্রাউন্ডিং উইথ Google Maps উইজেট" দেখুন।

প্রম্পটে স্থানের বৈশিষ্ট্য ব্যবহার করুন

এই বিভাগে স্থানের সেই বৈশিষ্ট্যগুলো তালিকাভুক্ত করা হয়েছে, যেগুলো অবস্থান বর্ণনা করতে এবং ‘গ্রাউন্ডিং উইথ Google Maps দ্বারা প্রতিক্রিয়া তৈরি করতে ব্যবহৃত হয়। এই বৈশিষ্ট্যগুলো ‘গ্রাউন্ডিং উইথ Google Maps কোন ধরনের প্রশ্নের উত্তর দিতে পারবে, তা নির্ধারণ করতে ব্যবহৃত হয়।

নমুনা স্থানের বৈশিষ্ট্য

এই তালিকাটি স্থান সম্পর্কিত এমন কিছু বৈশিষ্ট্যের বর্ণানুক্রমিক নমুনা প্রদান করে, যা আপনার মডেল প্রতিক্রিয়া তৈরি করতে ব্যবহার করতে পারে।

  • ঠিকানা
  • কার্বসাইড পিকআপ
  • ডেবিট কার্ড
  • দূরত্ব
  • বিনামূল্যে পার্কিং লট
  • লাইভ সঙ্গীত
  • শিশুদের জন্য মেনু
  • খোলার সময়
  • অর্থপ্রদানের বিকল্প (যেমন নগদ বা ক্রেডিট কার্ড )
  • উত্তর দিন
  • পোষা প্রাণীবান্ধব
  • বিয়ার পরিবেশন করে
  • নিরামিষ খাবার পরিবেশন করা হয়
  • হুইলচেয়ার প্রবেশযোগ্য
  • ওয়াইফাই

প্লেস অ্যানসারস হলো গ্রাউন্ডিং উইথ Google Maps পক্ষ থেকে ব্যবহারকারীদের রিভিউ থেকে প্রাপ্ত তথ্যের উপর ভিত্তি করে দেওয়া একটি প্রতিক্রিয়া।

স্থান বৈশিষ্ট্য ব্যবহার করে এমন উদাহরণ প্রম্পট।

The following examples use place properties in prompts about different types of places. Grounding with Google Maps uses the properties to understand your intent and then provides relevant answers based on the data associated with places in Google Maps .

  • Plan a family dinner : Determine if a restaurant is suitable for a family and if the restaurant offers a convenient service.

    • Example prompt: Is "The Italian Place" good for children, and do they offer takeout? What is their rating?
  • Check accessibility for a friend : Determine if the location meets specific accessibility needs.

    • Example prompt: I need a restaurant that has a wheelchair accessible entrance.
  • Find a location for a late-night snack : Find an open establishment serving a specific meal during a particular time.

    • Example prompt: Is "Burger Joint" open now? Do they serve dinner? What are their opening hours for Friday?
  • Meet a client for coffee : Assess the suitability of a cafe for a business meeting based on amenities, offerings, and payment options.

    • Example prompt: Does "Cafe Central" have Wifi? Do they serve coffee? What is their price level, and do they accept credit cards?

Note that information in the Google Maps Grounded Results might differ from actual conditions of the road.

How Grounding with Google Maps works

When you provide the model with the GoogleMaps tool, the model handles the entire workflow of searching, processing, and citing information automatically.

Here's the workflow of the model :

  1. Receives prompt : Your app sends a prompt to the Gemini model with the GoogleMaps tool enabled.

  2. Analyzes prompt : The model analyzes the prompt and determines if Google Maps can improve its response, for example, if the prompt contains geographical context (like "coffee shops near me," "museums in San Francisco").

  3. Invokes the tool : The model, recognizing the geographical intent, invokes the Grounding with Google Maps tool.

  4. Sends queries to Google Maps : The Grounding with Google Maps service queries Google Maps for relevant information (for example, places, reviews, photos, addresses, opening hours).

    You can optionally include latitude and longitude in the tool's config (or even just in the prompt directly) for more relevant and personalized Google Maps results. The tool is a textual search tool and behaves similarly to searching on Google Maps , in that local queries ("near me") will use the coordinates, while specific or non-local queries are unlikely to be influenced by the explicit location.

  5. Processes the Google Maps results : The model processes the Google Maps results and formulates a response to the original prompt.

  6. Returns a Google Maps Grounded Result : The model returns a final, user-friendly response that is grounded in the Google Maps results. This response includes:

    • The model's text answer.
    • A groundingMetadata object with the Google Maps results and sources.
    • (Web SDK only) Optionally a googleMapsWidgetContextToken that lets you render a contextual Google Maps widget in your app for visual interaction. For more information on the contextual widget, see Grounding with Google Maps widget in the Google Maps documentation.

Note that providing Google Maps as a tool to the model does not require the model to always use the Google Maps tool to generate its response. In these cases, the response won't contain a groundingMetadata object and thus it's not a Google Maps Grounded Result .

Understand the grounded result

If the model grounds its response in Google Maps results, then the response includes a groundingMetadata object that contains structured data that's essential for verifying claims and building a rich source experience in your application.

The groundingMetadata object in a Google Maps Grounded Result contains the following information:

  • groundingChunks : An array of objects containing the maps sources ( uri , placeId , and title ).
  • groundingSupports : An array of chunks to connect model response text to the sources in groundingChunks . Each chunk links a text segment (defined by startIndex and endIndex ) to one or more groundingChunkIndices . This field helps you build inline source links. Learn how to meet service usage requirements later on this page.
  • (Web SDK only) googleMapsWidgetContextToken : A text token that can be used to render a contextual Places widget . This field is only returned when using the Web SDK and if you've set the enableWidget parameter to true .

Here's an example response that includes a groundingMetadata object:

{
  "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/..."
      }
    }
  ]
}

Service usage requirements

This section describes the service usage requirements for Grounding with Google Maps for your chosen Gemini API provider: Gemini Developer API or Agent Platform Gemini API (formerly Vertex AI) (see Service Terms section within the Service Specific Terms).

Inform users of Google Maps sources

With each Google Maps Grounded Result , you'll receive sources in groundingChunks that support each response. The following metadata is also returned:

  • source uri
  • শিরোনাম
  • আইডি

In your app, when presenting results from Grounding with Google Maps , you must specify the associated Google Maps sources, and inform your users of the following:

  • The Google Maps sources must immediately follow the generated content that the sources support. This generated content is also referred to as Google Maps Grounded Result .

  • The Google Maps sources must be viewable within one user interaction.

Here's how to get values for displaying sources from the Google Maps Grounded Result :

সুইফট

// ...

// 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
  }
}

ঐক্য

// ...

// 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
    }
  }
}

For each source in groundingChunks , a link preview must be generated following these requirements:

  • Attribute each source to Google Maps following the Google Maps text attribution guidelines .
  • Display the source title provided in the response.
  • Link to the source using the uri from the response.

Prompt with response showing sources

You can collapse the view of the sources.

Prompt with response and sources collapsed

Optionally, you can enhance the link preview with additional content, such as:

  • A Google Maps favicon inserted before the Google Maps text attribution.
  • A photo from the source URL ( og:image ).

For more information about some of the Google Maps data providers and their license terms, see the Google Maps and Google Earth legal notices .

Google Maps text attribution guidelines

When you attribute sources to Google Maps within text, follow these guidelines:

  • Don't modify the text Google Maps in any way:

    • Don't change the capitalization of the text Google Maps .
    • Don't wrap the text Google Maps onto multiple lines.
    • Don't localize the text Google Maps into another language.
    • Prevent browsers from translating the text Google Maps by using the HTML attribute translate="no" .
  • Style the text Google Maps as described in the following table:

    Property শৈলী
    Font family Roboto. Loading the font is optional.
    Fallback font family Any sans serif body font already used in your product or "Sans-Serif" to invoke the default system font
    Font style স্বাভাবিক
    Font weight ৪০০
    Font color White, black (#1F1F1F), or gray (#5E5E5E). Maintain accessible (4.5:1) contrast against the background.
    ফন্টের আকার Minimum font size: 12sp
    Maximum font size: 16sp
    To learn about sp, see Font size units on the Material Design website .
    ব্যবধান স্বাভাবিক

Example CSS

The following CSS renders the text Google Maps with the appropriate typographic style and color on a white or light background.

@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;
}

Caching of context token and place ID

The Google Maps Grounded Result may include context token and place ID. You might cache, store, and export the following response data:

  • (Web SDK only) googleMapsWidgetContextToken
  • placeId

The restrictions against caching in the Grounding with Google Maps Terms don't apply to this data.

Prohibited activity and territories

Grounding with Google Maps has additional restrictions for certain content and activities to maintain a safe and reliable platform. In addition to the usage restrictions in the Terms for your chosen Gemini API provider: Gemini Developer API or Agent Platform Gemini API (formerly Vertex AI) (see Service Terms section within the Service Specific Terms).

  • You won't use Grounding with Google Maps for high risk activities including emergency response services.

  • You won't distribute or market your application that offers Grounding with Google Maps in a Prohibited Territory. For more information, see Google Maps Platform Prohibited Territories . The list of Prohibited Territories may be updated from time to time.

Grounded results and AI monitoring in the Firebase console

If you've enabled AI monitoring in the Firebase console , responses are stored in Cloud Logging . By default, this data has a 30-day retention period.

It's your responsibility to ensure that this retention period, or any custom period you set, fully aligns with your specific use case and any additional compliance requirements for your chosen Gemini API provider: Gemini Developer API or Agent Platform Gemini API (formerly Vertex AI) (see Service Terms section within the Service Specific Terms). You may need to adjust the retention period in Cloud Logging to meet these requirements.

Pricing and rate limits

Grounding with Google Maps pricing is based on queries. A request is only counted towards the Google Maps quota when a prompt successfully returns at least one Google Maps Grounded Result (meaning the response contains at least one Google Maps source). If multiple queries are sent to Google Maps from a single request, it counts as one request towards the rate limit.

Make sure to review details about pricing, model availability, and limits for Grounding with Google Maps in your chosen Gemini API provider documentation: Gemini Developer API |Agent Platform Gemini API (formerly Vertex AI) .