การเชื่อมต่อแหล่งข้อมูลกับ Google Maps จะเชื่อมต่อความสามารถในการสร้างของ Gemini กับข้อมูลที่สมบูรณ์ เป็นข้อเท็จจริง และเป็นข้อมูลล่าสุดของ Google Maps ฟีเจอร์นี้ช่วยให้นักพัฒนาแอปสามารถผสานรวมฟังก์ชันการทำงานที่รับรู้ตำแหน่งไว้ภายในแอปพลิเคชันได้อย่างง่ายดาย เมื่อคำค้นหาของผู้ใช้มีบริบทที่เกี่ยวข้องกับข้อมูล Maps โมเดล Gemini จะใช้ประโยชน์จาก Google Maps เพื่อให้คำตอบที่ถูกต้องตามข้อเท็จจริงและเป็นข้อมูลล่าสุด ซึ่ง เกี่ยวข้องกับสถานที่ที่ผู้ใช้ระบุหรือพื้นที่ทั่วไป
- คำตอบที่ถูกต้องและรับรู้ตำแหน่ง: ใช้ประโยชน์จากข้อมูลที่ครอบคลุมและ เป็นปัจจุบันของ Google Maps สำหรับคำค้นหาที่เจาะจงทางภูมิศาสตร์
- การปรับเปลี่ยนในแบบของคุณที่ดียิ่งขึ้น: ปรับแต่งคำแนะนำและข้อมูลตามตำแหน่งที่ผู้ใช้ระบุ
เริ่มต้นใช้งาน
ตัวอย่างนี้แสดงวิธีผสานรวมการเชื่อมต่อแหล่งข้อมูลกับ Google Maps เข้ากับแอปพลิเคชันของคุณเพื่อแสดงคำตอบที่แม่นยำและรับรู้ถึงตำแหน่งสำหรับคำค้นหาของผู้ใช้ พรอมต์ขอคำแนะนำในพื้นที่พร้อมตำแหน่งของผู้ใช้ (ไม่บังคับ) เพื่อให้ โมเดล Gemini ใช้ข้อมูล Google Maps ได้
Python
from google import genai
from google.genai import types
client = genai.Client()
prompt = "What are the best Italian restaurants within a 15-minute walk from here?"
response = client.models.generate_content(
model='gemini-3.8-flash',
contents=prompt,
config=types.GenerateContentConfig(
# Turn on grounding with Google Maps
tools=[types.Tool(google_maps=types.GoogleMaps())],
# Optionally provide the relevant location context (this is in Los Angeles)
tool_config=types.ToolConfig(retrieval_config=types.RetrievalConfig(
lat_lng=types.LatLng(
latitude=34.050481, longitude=-118.248526))),
),
)
print("Generated Response:")
print(response.text)
if grounding := response.candidates[0].grounding_metadata:
if grounding.grounding_chunks:
print('-' * 40)
print("Sources:")
for chunk in grounding.grounding_chunks:
print(f'- [{chunk.maps.title}]({chunk.maps.uri})')
JavaScript
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({});
async function generateContentWithMapsGrounding() {
const response = await ai.models.generateContent({
model: "gemini-3.8-flash",
contents: "What are the best Italian restaurants within a 15-minute walk from here?",
config: {
// Turn on grounding with Google Maps
tools: [{ googleMaps: {} }],
toolConfig: {
retrievalConfig: {
// Optionally provide the relevant location context (this is in Los Angeles)
latLng: {
latitude: 34.050481,
longitude: -118.248526,
},
},
},
},
});
console.log("Generated Response:");
console.log(response.text);
const grounding = response.candidates[0]?.groundingMetadata;
if (grounding?.groundingChunks) {
console.log("-".repeat(40));
console.log("Sources:");
for (const chunk of grounding.groundingChunks) {
if (chunk.maps) {
console.log(`- [${chunk.maps.title}](${chunk.maps.uri})`);
}
}
}
}
generateContentWithMapsGrounding();
REST
curl -X POST 'https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent' \
-H 'Content-Type: application/json' \
-H "x-goog-api-key: ${GEMINI_API_KEY}" \
-d '{
"contents": [{
"role": "user",
"parts": [{
"text": "What are the best Italian restaurants within a 15-minute walk from here?"
}]
}],
"tools": [{"googleMaps": {}}],
"toolConfig": {
"retrievalConfig": {
"latLng": {"latitude": 34.050481, "longitude": -118.248526}
}
}
}'
วิธีการทำงานของการเชื่อมต่อแหล่งข้อมูลกับ Google Maps
การเชื่อมต่อแหล่งข้อมูลกับ Google Maps จะผสานรวม Gemini API กับระบบนิเวศทางภูมิศาสตร์ของ Google โดยใช้ Maps API เป็นแหล่งข้อมูลที่เชื่อมต่อ เมื่อคำค้นหาของผู้ใช้ มีบริบททางภูมิศาสตร์ โมเดล Gemini จะเรียกใช้เครื่องมือการอ้างอิงกับ Google Maps ได้ จากนั้นโมเดลจะสร้างคำตอบโดยอิงตามข้อมูล Google Maps ที่เกี่ยวข้องกับตำแหน่งที่ระบุ
โดยปกติแล้วกระบวนการนี้จะมีขั้นตอนต่อไปนี้
- คำค้นหาของผู้ใช้: ผู้ใช้ส่งคำค้นหาไปยังแอปพลิเคชันของคุณ ซึ่งอาจ รวมถึงบริบททางภูมิศาสตร์ (เช่น "ร้านกาแฟใกล้ฉัน" "พิพิธภัณฑ์ใน ซานฟรานซิสโก")
- การเรียกใช้เครื่องมือ: โมเดล Gemini จะเรียกใช้เครื่องมือการเชื่อมต่อแหล่งข้อมูลกับ Google Maps เมื่อรับรู้ถึงความตั้งใจทางภูมิศาสตร์
เครื่องมือนี้อาจมี
latitudeและlongitudeของผู้ใช้ให้ด้วยก็ได้ เครื่องมือนี้เป็นเครื่องมือค้นหาแบบข้อความและทำงานคล้ายกับการค้นหาใน Maps โดยที่คำค้นหาในพื้นที่ ("ใกล้ฉัน") จะใช้พิกัด ส่วนคำค้นหาที่เฉพาะเจาะจงหรือไม่ใช่ในพื้นที่นั้นๆ จะไม่ได้รับผลกระทบจากตำแหน่งที่ระบุอย่างชัดเจน - การดึงข้อมูล: บริการการเชื่อมต่อแหล่งข้อมูลกับ Google Maps จะค้นหาข้อมูลที่เกี่ยวข้องใน Google Maps (เช่น สถานที่ รีวิว รูปภาพ ที่อยู่ เวลาทำการ)
- การสร้างข้อมูลที่อิงตามข้อมูลจริง: ระบบจะใช้ข้อมูล Maps ที่ดึงมาเพื่อแจ้งคำตอบของโมเดล Gemini เพื่อให้มั่นใจถึงความถูกต้องและความเกี่ยวข้องของข้อเท็จจริง
- คำตอบ: โมเดลจะแสดงคำตอบเป็นข้อความ ซึ่ง มีการอ้างอิงแหล่งที่มาจาก Google Maps
เหตุผลและเวลาที่ควรใช้การเชื่อมต่อแหล่งข้อมูลกับ Google Maps
การเชื่อมต่อแหล่งข้อมูลกับ Google Maps เหมาะสำหรับแอปพลิเคชันที่ต้องการข้อมูลที่ถูกต้อง เป็นปัจจุบัน และเฉพาะเจาะจงตำแหน่ง โดยจะช่วยยกระดับประสบการณ์ของผู้ใช้ ด้วยการแสดงเนื้อหาที่เกี่ยวข้องและปรับเปลี่ยนในแบบของคุณ ซึ่งขับเคลื่อนโดยฐานข้อมูลขนาดใหญ่ของ Google Maps ที่มีสถานที่กว่า 250 ล้านแห่งทั่วโลก
คุณควรใช้การเชื่อมต่อแหล่งข้อมูลกับ Google Maps เมื่อแอปพลิเคชันของคุณต้องการทำสิ่งต่อไปนี้
- ตอบคำถามที่เฉพาะเจาะจงตามภูมิศาสตร์ให้ถูกต้องและครบถ้วน
- สร้างผู้ช่วยวางแผนการเดินทางและ Local Guides แบบสนทนา
- แนะนำจุดที่น่าสนใจตาม ตำแหน่งและความชอบของผู้ใช้ เช่น ร้านอาหารหรือร้านค้า
- สร้างประสบการณ์ที่รับรู้ตำแหน่งสำหรับบริการโซเชียล การค้าปลีก หรือการนำส่งอาหาร
การเชื่อมต่อแหล่งข้อมูลกับ Google Maps เหมาะอย่างยิ่งสำหรับ Use Case ที่ต้องใช้ข้อมูลความใกล้ชิดและข้อมูลข้อเท็จจริงปัจจุบัน เช่น การค้นหา "ร้านกาแฟที่ดีที่สุดใกล้ฉัน" หรือการขอเส้นทาง
เมธอดและพารามิเตอร์ของ API
การเชื่อมต่อแหล่งข้อมูลกับ Google Maps จะแสดงผ่าน Gemini API เป็นเครื่องมือภายในเมธอด generateContent คุณเปิดใช้และกำหนดค่า
การเชื่อมต่อแหล่งข้อมูลกับ Google Maps ได้โดยรวมออบเจ็กต์
googleMaps ไว้ในพารามิเตอร์ tools ของคำขอ
JSON
{
"contents": [{
"parts": [
{"text": "Restaurants near Times Square."}
]
}],
"tools": { "googleMaps": {} }
}
นอกจากนี้ เครื่องมือยังรองรับการส่งตำแหน่งตามบริบทเป็น toolConfig ด้วย
JSON
{
"contents": [{
"parts": [
{"text": "Restaurants near here."}
]
}],
"tools": { "googleMaps": {} },
"toolConfig": {
"retrievalConfig": {
"latLng": {
"latitude": 40.758896,
"longitude": -73.985130
}
}
}
}
ทำความเข้าใจคำตอบที่อ้างอิง
เมื่อการตอบกลับอิงตามข้อมูล Google Maps สำเร็จ การตอบกลับจะมีฟิลด์ groundingMetadata
Structured Data นี้มีความสำคัญต่อการยืนยันการอ้างสิทธิ์และการสร้างประสบการณ์การอ้างอิงที่สมบูรณ์ในแอปพลิเคชันของคุณ รวมถึงการปฏิบัติตามข้อกำหนดในการใช้งานบริการ
JSON
{
"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"
},
// repeated ...
}
],
"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]
},
// repeated ...
],
"webSearchQueries": [
"restaurants near me"
]
}
}
]
}
Gemini API จะแสดงข้อมูลต่อไปนี้พร้อมกับ
groundingMetadata
groundingChunks: อาร์เรย์ของออบเจ็กต์ที่มีแหล่งที่มาของmaps(uri,placeIdและtitle)groundingSupports: อาร์เรย์ของก้อนข้อมูลเพื่อเชื่อมต่อข้อความคำตอบของโมเดลกับ แหล่งที่มาในgroundingChunksแต่ละก้อนจะลิงก์ช่วงข้อความ (กำหนดโดยstartIndexและendIndex) กับgroundingChunkIndicesอย่างน้อย 1 รายการ นี่คือ เคล็ดลับในการสร้างการอ้างอิงในบรรทัด
ดูข้อมูลโค้ดที่แสดงวิธีแสดงผลการอ้างอิงในข้อความได้ที่ตัวอย่าง ในเอกสารการเชื่อมต่อแหล่งข้อมูลกับ Google Search
กรณีการใช้งาน
การเชื่อมต่อแหล่งข้อมูลกับ Google Maps รองรับกรณีการใช้งานที่หลากหลายซึ่งรับรู้ตำแหน่ง ตัวอย่างต่อไปนี้แสดงให้เห็นว่าพรอมต์และพารามิเตอร์ต่างๆ สามารถใช้ประโยชน์จากการเชื่อมต่อแหล่งข้อมูลกับ Google Maps ได้อย่างไร ข้อมูลในผลลัพธ์แบบกราวด์ของ Google Maps อาจ แตกต่างจากสภาพจริง
การจัดการคำถามเกี่ยวกับสถานที่
ถามคำถามโดยละเอียดเกี่ยวกับสถานที่ที่เฉพาะเจาะจงเพื่อรับคำตอบตามรีวิวของผู้ใช้ Google และข้อมูลอื่นๆ ของ Maps
Python
from google import genai
from google.genai import types
client = genai.Client()
prompt = "Is there a cafe near the corner of 1st and Main that has outdoor seating?"
response = client.models.generate_content(
model='gemini-3.8-flash',
contents=prompt,
config=types.GenerateContentConfig(
# Turn on the Maps tool
tools=[types.Tool(google_maps=types.GoogleMaps())],
# Provide the relevant location context (this is in Los Angeles)
tool_config=types.ToolConfig(retrieval_config=types.RetrievalConfig(
lat_lng=types.LatLng(
latitude=34.050481, longitude=-118.248526))),
),
)
print("Generated Response:")
print(response.text)
if grounding := response.candidates[0].grounding_metadata:
if chunks := grounding.grounding_chunks:
print('-' * 40)
print("Sources:")
for chunk in chunks:
print(f'- [{chunk.maps.title}]({chunk.maps.uri})')
```
JavaScript
import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI({});
async function run() {
const prompt = "Is there a cafe near the corner of 1st and Main that has outdoor seating?";
const response = await ai.models.generateContent({
model: 'gemini-3.8-flash',
contents: prompt,
config: {
// Turn on the Maps tool
tools: [{googleMaps: {}}],
// Provide the relevant location context (this is in Los Angeles)
toolConfig: {
retrievalConfig: {
latLng: {
latitude: 34.050481,
longitude: -118.248526
}
}
}
},
});
console.log("Generated Response:");
console.log(response.text);
const chunks = response.candidates[0].groundingMetadata?.groundingChunks;
if (chunks) {
console.log('-'.repeat(40));
console.log("Sources:");
for (const chunk of chunks) {
if (chunk.maps) {
console.log(`- [${chunk.maps.title}](${chunk.maps.uri})`);
}
}
}
}
run();
REST
curl -X POST 'https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent' \
-H 'Content-Type: application/json' \
-H "x-goog-api-key: ${GEMINI_API_KEY}" \
-d '{
"contents": [{
"role": "user",
"parts": [{
"text": "Is there a cafe near the corner of 1st and Main that has outdoor seating?"
}]
}],
"tools": [{"googleMaps": {}}],
"toolConfig": {
"retrievalConfig": {
"latLng": {"latitude": 34.050481, "longitude": -118.248526}
}
}
}'
การปรับเปลี่ยนในแบบของคุณตามตำแหน่ง
รับคำแนะนำที่ปรับให้เหมาะกับค่ากำหนดของผู้ใช้และพื้นที่ทางภูมิศาสตร์ที่เฉพาะเจาะจง
Python
from google import genai
from google.genai import types
client = genai.Client()
prompt = "Which family-friendly restaurants near here have the best playground reviews?"
response = client.models.generate_content(
model='gemini-3.8-flash',
contents=prompt,
config=types.GenerateContentConfig(
tools=[types.Tool(google_maps=types.GoogleMaps())],
tool_config=types.ToolConfig(retrieval_config=types.RetrievalConfig(
# Provide the location as context; this is Austin, TX.
lat_lng=types.LatLng(
latitude=30.2672, longitude=-97.7431))),
),
)
print("Generated Response:")
print(response.text)
if grounding := response.candidates[0].grounding_metadata:
if chunks := grounding.grounding_chunks:
print('-' * 40)
print("Sources:")
for chunk in chunks:
print(f'- [{chunk.maps.title}]({chunk.maps.uri})')
JavaScript
import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI({});
async function run() {
const prompt = "Which family-friendly restaurants near here have the best playground reviews?";
const response = await ai.models.generateContent({
model: 'gemini-3.8-flash',
contents: prompt,
config: {
tools: [{googleMaps: {}}],
toolConfig: {
retrievalConfig: {
// Provide the location as context; this is Austin, TX.
latLng: {
latitude: 30.2672,
longitude: -97.7431
}
}
}
},
});
console.log("Generated Response:");
console.log(response.text);
const chunks = response.candidates[0].groundingMetadata?.groundingChunks;
if (chunks) {
console.log('-'.repeat(40));
console.log("Sources:");
for (const chunk of chunks) {
if (chunk.maps) {
console.log(`- [${chunk.maps.title}](${chunk.maps.uri})`);
}
}
}
}
run();
REST
curl -X POST 'https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent' \
-H 'Content-Type: application/json' \
-H "x-goog-api-key: ${GEMINI_API_KEY}" \
-d '{
"contents": [{
"role": "user",
"parts": [{
"text": "Which family-friendly restaurants near here have the best playground reviews?"
}],
}],
"tools": [{"googleMaps": {}}],
"toolConfig": {
"retrievalConfig": {
"latLng": {"latitude": 30.2672, "longitude": -97.7431}
}
}
}'
ช่วยวางแผนการเดินทาง
สร้างแผนการเดินทางหลายวันพร้อมเส้นทางและข้อมูลเกี่ยวกับสถานที่ต่างๆ เหมาะสำหรับแอปพลิเคชันการเดินทาง
Python
from google import genai
from google.genai import types
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."
response = client.models.generate_content(
model='gemini-3.8-flash',
contents=prompt,
config=types.GenerateContentConfig(
tools=[types.Tool(google_maps=types.GoogleMaps())],
tool_config=types.ToolConfig(retrieval_config=types.RetrievalConfig(
# Provide the location as context, this is in San Francisco.
lat_lng=types.LatLng(
latitude=37.78193, longitude=-122.40476))),
),
)
print("Generated Response:")
print(response.text)
if grounding := response.candidates[0].grounding_metadata:
if grounding.grounding_chunks:
print('-' * 40)
print("Sources:")
for chunk in grounding.grounding_chunks:
print(f'- [{chunk.maps.title}]({chunk.maps.uri})')
JavaScript
import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI({});
async function run() {
const 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.";
const response = await ai.models.generateContent({
model: 'gemini-3.8-flash',
contents: prompt,
config: {
tools: [{googleMaps: {}}],
toolConfig: {
retrievalConfig: {
// Provide the location as context, this is in San Francisco.
latLng: {
latitude: 37.78193,
longitude: -122.40476
}
}
}
},
});
console.log("Generated Response:");
console.log(response.text);
const groundingMetadata = response.candidates[0]?.groundingMetadata;
if (groundingMetadata) {
if (groundingMetadata.groundingChunks) {
console.log('-'.repeat(40));
console.log("Sources:");
for (const chunk of groundingMetadata.groundingChunks) {
if (chunk.maps) {
console.log(`- [${chunk.maps.title}](${chunk.maps.uri})`);
}
}
}
}
}
run();
REST
curl -X POST 'https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent' \
-H 'Content-Type: application/json' \
-H "x-goog-api-key: ${GEMINI_API_KEY}" \
-d '{
"contents": [{
"role": "user",
"parts": [{
"text": "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": [{"googleMaps": {}}],
"toolConfig": {
"retrievalConfig": {
"latLng": {"latitude": 37.78193, "longitude": -122.40476}
}
}
}'
ข้อกำหนดในการใช้งานบริการ
ส่วนนี้อธิบายข้อกำหนดในการใช้งานบริการสำหรับ Grounding with Google Maps
แจ้งให้ผู้ใช้ทราบเกี่ยวกับการใช้แหล่งข้อมูลของ Google Maps
ผลการค้นหาที่อิงตามข้อมูลจริงของ Google Maps แต่ละรายการจะมาพร้อมกับแหล่งข้อมูลใน
groundingChunks ที่สนับสนุนคำตอบแต่ละรายการ ระบบจะแสดงข้อมูลเมตาต่อไปนี้ด้วย
- URI ต้นทาง
- title
- รหัส
เมื่อแสดงผลลัพธ์จากการเชื่อมต่อแหล่งข้อมูลกับ Google Maps คุณต้องระบุแหล่งที่มาของ Google Maps ที่เกี่ยวข้อง และแจ้งให้ผู้ใช้ทราบข้อมูลต่อไปนี้
- แหล่งที่มาของ Google Maps ต้องอยู่ต่อจากเนื้อหาที่สร้างขึ้นซึ่งแหล่งที่มานั้นรองรับ เนื้อหาที่สร้างขึ้นนี้เรียกอีกอย่างว่าผลการค้นหาที่อิงตามข้อมูลภาคพื้นดินของ Google Maps
- แหล่งข้อมูล Google Maps ต้องดูได้ภายใน 1 การโต้ตอบของผู้ใช้
แสดงแหล่งข้อมูล Google Maps ด้วยลิงก์ Maps
สำหรับแหล่งที่มาแต่ละแห่งใน groundingChunks และใน
grounding_chunks.maps.placeAnswerSources.reviewSnippets จะต้องสร้างตัวอย่างลิงก์ตามข้อกำหนดต่อไปนี้
- ระบุแหล่งที่มาแต่ละแหล่งเป็น Google Maps โดยทำตามหลักเกณฑ์การระบุแหล่งที่มาของข้อความ Google Maps
- แสดงชื่อแหล่งข้อมูลที่ระบุในคำตอบ
- ลิงก์ไปยังแหล่งที่มาโดยใช้
uriหรือgoogleMapsUriจากคำตอบ
รูปภาพเหล่านี้แสดงข้อกำหนดขั้นต่ำสำหรับการแสดงแหล่งที่มาและลิงก์ Google Maps
คุณยุบมุมมองของแหล่งข้อมูลได้
ไม่บังคับ: ปรับปรุงตัวอย่างลิงก์ด้วยเนื้อหาเพิ่มเติม เช่น
- Favicon ของ Google Maps จะแทรกอยู่ก่อนข้อความระบุแหล่งที่มาของ Google Maps
- รูปภาพจาก URL แหล่งที่มา (
og:image)
ดูข้อมูลเพิ่มเติมเกี่ยวกับผู้ให้บริการข้อมูล Google Maps บางรายและข้อกำหนดของใบอนุญาตได้ที่ประกาศทางกฎหมายของ Google Maps และ Google Earth
หลักเกณฑ์การระบุแหล่งที่มาด้วยข้อความของ Google Maps
เมื่อระบุแหล่งที่มาของ Google Maps ในข้อความ ให้ทำตามหลักเกณฑ์ต่อไปนี้
- โปรดอย่าแก้ไขข้อความ Google Maps ในลักษณะใดก็ตาม
- อย่าเปลี่ยนการใช้อักษรตัวพิมพ์ใหญ่ของ Google Maps
- อย่าวาง Google Maps ในหลายบรรทัด
- อย่าแปล Google Maps เป็นภาษาอื่น
- ป้องกันไม่ให้เบราว์เซอร์แปล Google Maps โดยใช้แอตทริบิวต์ HTML translate="no"
- จัดรูปแบบข้อความ Google Maps ตามที่อธิบายไว้ในตารางต่อไปนี้
| พร็อพเพอร์ตี้ | รูปแบบ |
|---|---|
Font family |
Roboto คุณจะโหลดแบบอักษรหรือไม่ก็ได้ |
Fallback font family |
แบบอักษรเนื้อหาแบบ Sans Serif ที่ใช้ในผลิตภัณฑ์อยู่แล้ว หรือ "Sans-Serif" เพื่อเรียกใช้แบบอักษรเริ่มต้นของระบบ |
Font style |
ปกติ |
Font weight |
400 |
Font color |
สีขาว สีดำ (#1F1F1F) หรือสีเทา (#5E5E5E) รักษาระดับความแตกต่างที่เข้าถึงได้ (4.5:1) กับพื้นหลัง |
Font size |
|
Spacing |
ปกติ |
ตัวอย่าง CSS
CSS ต่อไปนี้จะแสดง Google Maps ด้วยรูปแบบการพิมพ์และ สีที่เหมาะสมบนพื้นหลังสีขาวหรือสีอ่อน
CSS
@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 ประกอบด้วยรหัสสถานที่และรหัสรีวิว คุณอาจแคช จัดเก็บ และส่งออกข้อมูลการตอบกลับต่อไปนี้
placeIdreviewId
ข้อจำกัดในการแคชในข้อกำหนดการเชื่อมต่อแหล่งข้อมูลกับ Google Maps จะไม่มีผล
กิจกรรมและเขตแดนที่ไม่อนุญาต
การใช้ฟีเจอร์กราวด์ร่วมกับ Google Maps มีข้อจำกัดเพิ่มเติมสำหรับเนื้อหาและ กิจกรรมบางอย่างเพื่อรักษาแพลตฟอร์มให้ปลอดภัยและเชื่อถือได้ นอกเหนือจากข้อจำกัดในการใช้งานในข้อกำหนดแล้ว
- คุณจะไม่ใช้ Grounding กับ Google Maps สำหรับกิจกรรมที่มีความเสี่ยงสูง ซึ่งรวมถึง บริการตอบสนองต่อเหตุฉุกเฉิน
- คุณจะไม่จัดจำหน่ายหรือทำการตลาดแอปพลิเคชันที่ให้บริการการกราวด์ด้วย Google Maps ในเขตแดนที่ถูกห้าม ดูข้อมูลเพิ่มเติมได้ที่เขตแดนที่ไม่อนุญาตของ Google Maps Platform รายชื่อเขตแดนที่ถูกห้ามอาจมีการอัปเดตเป็นครั้งคราว
แนวทางปฏิบัติแนะนำ
- ระบุตำแหน่งของผู้ใช้: เพื่อให้ได้คำตอบที่เกี่ยวข้องและปรับเปลี่ยนในแบบของคุณมากที่สุด
ให้ใส่
user_location(ละติจูดและลองจิจูด) ในการกำหนดค่าgoogleMapsGroundingเสมอเมื่อทราบตำแหน่งของผู้ใช้ - แจ้งผู้ใช้ปลายทาง: แจ้งให้ผู้ใช้ปลายทางทราบอย่างชัดเจนว่าระบบกำลังใช้ข้อมูล Google Maps เพื่อตอบคำค้นหาของผู้ใช้ โดยเฉพาะอย่างยิ่งเมื่อเปิดใช้เครื่องมือ
- ตรวจสอบเวลาในการตอบสนอง: สำหรับแอปพลิเคชันแบบสนทนา ให้ตรวจสอบว่าเวลาในการตอบสนอง P95 สำหรับคำตอบที่อิงตามข้อมูลยังคงอยู่ภายในเกณฑ์ที่ยอมรับได้เพื่อ รักษาประสบการณ์ของผู้ใช้ให้ราบรื่น
- ปิดเมื่อไม่จำเป็น: การเชื่อมต่อแหล่งข้อมูลกับ Google Maps จะปิดอยู่โดยค่าเริ่มต้น เปิดใช้ (
"tools": [{"googleMaps": {}}]) เมื่อการค้นหามีบริบททางภูมิศาสตร์ที่ชัดเจนเท่านั้น เพื่อเพิ่มประสิทธิภาพและต้นทุน
ข้อจำกัด
- ขอบเขตทางภูมิศาสตร์: การเชื่อมต่อแหล่งข้อมูลกับ Google Maps พร้อมให้บริการทั่วโลก
- การรองรับโมเดล: ดูส่วนโมเดลที่รองรับ
- อินพุต/เอาต์พุตหลายรูปแบบ: ปัจจุบันการเชื่อมต่อแหล่งข้อมูลกับ Google Maps ไม่รองรับอินพุตหรือเอาต์พุตหลายรูปแบบนอกเหนือจากข้อความ
- สถานะเริ่มต้น: เครื่องมือการเชื่อมต่อแหล่งข้อมูลกับ Google Maps จะปิดอยู่โดยค่าเริ่มต้น คุณต้องเปิดใช้โดยชัดแจ้งในคำขอ API
การกำหนดราคาและการจำกัดอัตราคำขอ
ราคาการเชื่อมต่อแหล่งข้อมูลกับ Google Maps จะแตกต่างกันไปตามรุ่นของโมเดล ดังนี้
- โมเดล Gemini 3 ขึ้นไป: ระบบจะเรียกเก็บเงินจากโปรเจ็กต์ของคุณสำหรับคำค้นหาแต่ละรายการ ที่โมเดลตัดสินใจดำเนินการ โดยมีคำขอฟรี 5,000 รายการต่อเดือนที่ใช้ร่วมกัน ในโมเดล Gemini 3 ขึ้นไปทั้งหมด จากนั้นจะเรียกเก็บเงิน $14 ต่อคำค้นหา 1,000 รายการ พรอมต์การค้นหาเดียว (คำขอ API ของคุณไปยังโมเดล) อาจส่งผลให้โมเดลดำเนินการคำค้นหาหลายรายการเพื่อค้นหาข้อมูลที่จำเป็น คำค้นหาแต่ละรายการเหล่านี้จะนับเป็นการใช้เครื่องมือที่เรียกเก็บเงินได้
- โมเดล Gemini 2.5 และรุ่นเก่ากว่า: ระบบจะเรียกเก็บเงินจากโปรเจ็กต์ของคุณต่อพรอมต์การค้นหา ($25 ต่อพรอมต์ที่อิงตามข้อมูลจริง 1,000 รายการ) ระบบจะเรียกเก็บเงินคำขอเฉพาะในกรณีที่พรอมต์ แสดงผลลัพธ์ที่อิงตาม Google Maps อย่างน้อย 1 รายการสำเร็จ ไม่ว่าโมเดลจะทำการค้นหาแต่ละรายการภายในกี่ครั้งก็ตามเพื่อรับผลลัพธ์นั้น
โดยปกติแล้ว โควต้าสำหรับการเชื่อมต่อแหล่งข้อมูลกับ Google Maps จะสอดคล้องกับขีดจำกัดอัตราของโมเดล Gemini ที่เกี่ยวข้อง ดูข้อมูลการกำหนดราคาแบบละเอียดได้ที่หน้าราคาของ Gemini API
รุ่นที่รองรับ
รุ่นต่อไปนี้รองรับการเชื่อมต่อแหล่งข้อมูลกับ Google Maps
| รุ่น | การเชื่อมต่อแหล่งข้อมูลกับ Google Maps |
|---|---|
| Gemini 3.8 Flash | ✔️ |
| Gemini 3.6 Flash | ✔️ |
| Gemini 3.5 Flash-Lite | ✔️ |
| Gemini 3.1 Pro เวอร์ชันตัวอย่าง | ✔️ |
| Gemini 3.1 Flash-Lite | ✔️ |
| ตัวอย่าง Gemini 3 Flash | ✔️ |
| Gemini 2.5 Pro | ✔️ |
| Gemini 2.5 Flash | ✔️ |
| Gemini 2.5 Flash-Lite | ✔️ |
ชุดเครื่องมือที่รองรับ
คุณสามารถใช้การเชื่อมต่อแหล่งข้อมูลกับ Google Maps ร่วมกับเครื่องมืออื่นๆ ในตัว เช่น การเชื่อมต่อแหล่งข้อมูลกับ Google Search (รองรับใน Gemini 3.5 Flash-Lite และรุ่นที่ใหม่กว่า) เพื่อขับเคลื่อน Use Case ที่ซับซ้อนยิ่งขึ้น โมเดล Gemini 3 ยังรองรับการรวมเครื่องมือในตัวเหล่านี้กับเครื่องมือที่กำหนดเอง (การเรียกใช้ฟังก์ชัน) ด้วย ดูข้อมูลเพิ่มเติมได้ที่หน้าชุดเครื่องมือ
ขั้นตอนถัดไป
- ลองใช้การเชื่อมต่อแหล่งข้อมูลกับ Google Search ในสูตรการแก้ปัญหาของ Gemini API
- ดูข้อมูลเกี่ยวกับเครื่องมืออื่นๆ ที่มีให้ใช้งาน
- ดูข้อมูลเพิ่มเติมเกี่ยวกับแนวทางปฏิบัติแนะนำด้าน AI ที่มีความรับผิดชอบและตัวกรองความปลอดภัยของ Gemini API ได้ที่คู่มือการตั้งค่าความปลอดภัย