קוד מקור מלא לדוגמה
מחפשים מקומות כדי לראות את הסיכומים מבוססי-AI. הנה כמה הצעות לחיפוש:
- 'Hotel' (מלון) לסיכומים של שכונות.
- "EV charging station" (תחנת טעינה לרכב חשמלי) לסיכומים של שירותים בתחנות טעינה לרכבים חשמליים.
- כל מסעדה או עסק שמופיעים בסיכומי המקום והביקורות.
TypeScript
// Define DOM elements. const mapElement = document.querySelector('gmp-map') as google.maps.MapElement; const placeAutocomplete = document.querySelector( 'gmp-place-autocomplete' ) as google.maps.places.PlaceAutocompleteElement; const summaryPanel = document.getElementById('summary-panel') as HTMLDivElement; const placeName = document.getElementById('place-name') as HTMLElement; const placeAddress = document.getElementById('place-address') as HTMLElement; const tabContainer = document.getElementById('tab-container') as HTMLDivElement; const summaryContent = document.getElementById( 'summary-content' ) as HTMLDivElement; const aiDisclosure = document.getElementById('ai-disclosure') as HTMLDivElement; const flagContentLink = document.getElementById('flag-content-link') as HTMLAnchorElement; let innerMap; let marker: google.maps.marker.AdvancedMarkerElement; async function initMap(): Promise<void> { // Request needed libraries. const [] = await Promise.all([ google.maps.importLibrary('marker'), google.maps.importLibrary('places'), ]); innerMap = mapElement.innerMap; innerMap.setOptions({ mapTypeControl: false, streetViewControl: false, fullscreenControl: false, }); // Bind autocomplete bounds to map bounds. google.maps.event.addListener(innerMap, 'bounds_changed', async () => { placeAutocomplete.locationRestriction = innerMap.getBounds(); }); // Create the marker. marker = new google.maps.marker.AdvancedMarkerElement({ map: innerMap, }); // Handle selection of an autocomplete result. // prettier-ignore // @ts-ignore placeAutocomplete.addEventListener('gmp-select', async ({ placePrediction }) => { const place = placePrediction.toPlace(); // Fetch all summary fields. await place.fetchFields({ fields: [ 'displayName', 'formattedAddress', 'location', 'generativeSummary', 'neighborhoodSummary', 'reviewSummary', 'evChargeAmenitySummary', ], }); // Update the map viewport and position the marker. if (place.viewport) { innerMap.fitBounds(place.viewport); } else { innerMap.setCenter(place.location); innerMap.setZoom(17); } marker.position = place.location; // Update the panel UI. updateSummaryPanel(place); } ); } function updateSummaryPanel(place: google.maps.places.Place) { // Reset UI summaryPanel.classList.remove('hidden'); tabContainer.innerHTML = ''; // innerHTML is OK here since we're clearing known child elements. summaryContent.textContent = ''; aiDisclosure.textContent = ''; placeName.textContent = place.displayName || ''; placeAddress.textContent = place.formattedAddress || ''; let firstTabActivated = false; /** * Safe Helper: Accepts either a text string or a DOM Node (like a div or DocumentFragment). */ const createTab = ( label: string, content: string | Node, disclosure: string, flagUrl: string ) => { const btn = document.createElement('button'); btn.className = 'tab-button'; btn.textContent = label; btn.onclick = () => { // Do nothing if the tab is already active. if (btn.classList.contains('active')) { return; } // Manage the active class state. document .querySelectorAll('.tab-button') .forEach((b) => b.classList.remove('active')); btn.classList.add('active'); if (typeof content === 'string') { summaryContent.textContent = content; } else { summaryContent.replaceChildren(content.cloneNode(true)); } // Set the disclosure text. aiDisclosure.textContent = disclosure || 'AI-generated content.'; // Add the content flag URI. if (flagUrl) { flagContentLink.href = flagUrl; flagContentLink.textContent = "Report an issue" } }; tabContainer.appendChild(btn); // Auto-select the first available summary. if (!firstTabActivated) { btn.click(); firstTabActivated = true; } }; // --- 1. Generative Summary (Place) --- //@ts-ignore if (place.generativeSummary?.overview) { createTab( 'Overview', //@ts-ignore place.generativeSummary.overview, //@ts-ignore place.generativeSummary.disclosureText, //@ts-ignore place.generativeSummary.flagContentURI ); } // --- 2. Review Summary --- //@ts-ignore if (place.reviewSummary?.text) { createTab( 'Reviews', //@ts-ignore place.reviewSummary.text, //@ts-ignore place.reviewSummary.disclosureText, //@ts-ignore place.reviewSummary.flagContentURI ); } // --- 3. Neighborhood Summary --- //@ts-ignore if (place.neighborhoodSummary?.overview?.content) { createTab( 'Neighborhood', //@ts-ignore place.neighborhoodSummary.overview.content, //@ts-ignore place.neighborhoodSummary.disclosureText, //@ts-ignore place.neighborhoodSummary.flagContentURI ); } // --- 4. EV Amenity Summary (uses content blocks)) --- //@ts-ignore if (place.evChargeAmenitySummary) { //@ts-ignore const evSummary = place.evChargeAmenitySummary; const evContainer = document.createDocumentFragment(); // Helper to build a safe DOM section for EV categories. const createSection = (title: string, text: string) => { const wrapper = document.createElement('div'); wrapper.style.marginBottom = '15px'; // Or use a CSS class const titleEl = document.createElement('strong'); titleEl.textContent = title; const textEl = document.createElement('div'); textEl.textContent = text; wrapper.appendChild(titleEl); wrapper.appendChild(textEl); return wrapper; }; // Check and append each potential section if (evSummary.overview?.content) { evContainer.appendChild( createSection('Overview', evSummary.overview.content) ); } if (evSummary.coffee?.content) { evContainer.appendChild( createSection('Coffee', evSummary.coffee.content) ); } if (evSummary.restaurant?.content) { evContainer.appendChild( createSection('Food', evSummary.restaurant.content) ); } if (evSummary.store?.content) { evContainer.appendChild( createSection('Shopping', evSummary.store.content) ); } // Only add the tab if the container has children if (evContainer.hasChildNodes()) { createTab( 'EV Amenities', evContainer, // Passing a Node instead of string evSummary.disclosureText, evSummary.flagContentURI ); } } // Safely handle the empty state. if (!firstTabActivated) { const msg = document.createElement('em'); msg.textContent = 'No AI summaries are available for this specific location.'; summaryContent.replaceChildren(msg); aiDisclosure.textContent = ''; } } initMap();
JavaScript
// Define DOM elements. const mapElement = document.querySelector('gmp-map'); const placeAutocomplete = document.querySelector('gmp-place-autocomplete'); const summaryPanel = document.getElementById('summary-panel'); const placeName = document.getElementById('place-name'); const placeAddress = document.getElementById('place-address'); const tabContainer = document.getElementById('tab-container'); const summaryContent = document.getElementById('summary-content'); const aiDisclosure = document.getElementById('ai-disclosure'); const flagContentLink = document.getElementById('flag-content-link'); let innerMap; let marker; async function initMap() { // Request needed libraries. const [] = await Promise.all([ google.maps.importLibrary('marker'), google.maps.importLibrary('places'), ]); innerMap = mapElement.innerMap; innerMap.setOptions({ mapTypeControl: false, streetViewControl: false, fullscreenControl: false, }); // Bind autocomplete bounds to map bounds. google.maps.event.addListener(innerMap, 'bounds_changed', async () => { placeAutocomplete.locationRestriction = innerMap.getBounds(); }); // Create the marker. marker = new google.maps.marker.AdvancedMarkerElement({ map: innerMap, }); // Handle selection of an autocomplete result. // prettier-ignore // @ts-ignore placeAutocomplete.addEventListener('gmp-select', async ({ placePrediction }) => { const place = placePrediction.toPlace(); // Fetch all summary fields. await place.fetchFields({ fields: [ 'displayName', 'formattedAddress', 'location', 'generativeSummary', 'neighborhoodSummary', 'reviewSummary', 'evChargeAmenitySummary', ], }); // Update the map viewport and position the marker. if (place.viewport) { innerMap.fitBounds(place.viewport); } else { innerMap.setCenter(place.location); innerMap.setZoom(17); } marker.position = place.location; // Update the panel UI. updateSummaryPanel(place); }); } function updateSummaryPanel(place) { // Reset UI summaryPanel.classList.remove('hidden'); tabContainer.innerHTML = ''; // innerHTML is OK here since we're clearing known child elements. summaryContent.textContent = ''; aiDisclosure.textContent = ''; placeName.textContent = place.displayName || ''; placeAddress.textContent = place.formattedAddress || ''; let firstTabActivated = false; /** * Safe Helper: Accepts either a text string or a DOM Node (like a div or DocumentFragment). */ const createTab = (label, content, disclosure, flagUrl) => { const btn = document.createElement('button'); btn.className = 'tab-button'; btn.textContent = label; btn.onclick = () => { // Do nothing if the tab is already active. if (btn.classList.contains('active')) { return; } // Manage the active class state. document .querySelectorAll('.tab-button') .forEach((b) => b.classList.remove('active')); btn.classList.add('active'); if (typeof content === 'string') { summaryContent.textContent = content; } else { summaryContent.replaceChildren(content.cloneNode(true)); } // Set the disclosure text. aiDisclosure.textContent = disclosure || 'AI-generated content.'; // Add the content flag URI. if (flagUrl) { flagContentLink.href = flagUrl; flagContentLink.textContent = "Report an issue"; } }; tabContainer.appendChild(btn); // Auto-select the first available summary. if (!firstTabActivated) { btn.click(); firstTabActivated = true; } }; // --- 1. Generative Summary (Place) --- //@ts-ignore if (place.generativeSummary?.overview) { createTab('Overview', //@ts-ignore place.generativeSummary.overview, //@ts-ignore place.generativeSummary.disclosureText, //@ts-ignore place.generativeSummary.flagContentURI); } // --- 2. Review Summary --- //@ts-ignore if (place.reviewSummary?.text) { createTab('Reviews', //@ts-ignore place.reviewSummary.text, //@ts-ignore place.reviewSummary.disclosureText, //@ts-ignore place.reviewSummary.flagContentURI); } // --- 3. Neighborhood Summary --- //@ts-ignore if (place.neighborhoodSummary?.overview?.content) { createTab('Neighborhood', //@ts-ignore place.neighborhoodSummary.overview.content, //@ts-ignore place.neighborhoodSummary.disclosureText, //@ts-ignore place.neighborhoodSummary.flagContentURI); } // --- 4. EV Amenity Summary (uses content blocks)) --- //@ts-ignore if (place.evChargeAmenitySummary) { //@ts-ignore const evSummary = place.evChargeAmenitySummary; const evContainer = document.createDocumentFragment(); // Helper to build a safe DOM section for EV categories. const createSection = (title, text) => { const wrapper = document.createElement('div'); wrapper.style.marginBottom = '15px'; // Or use a CSS class const titleEl = document.createElement('strong'); titleEl.textContent = title; const textEl = document.createElement('div'); textEl.textContent = text; wrapper.appendChild(titleEl); wrapper.appendChild(textEl); return wrapper; }; // Check and append each potential section if (evSummary.overview?.content) { evContainer.appendChild(createSection('Overview', evSummary.overview.content)); } if (evSummary.coffee?.content) { evContainer.appendChild(createSection('Coffee', evSummary.coffee.content)); } if (evSummary.restaurant?.content) { evContainer.appendChild(createSection('Food', evSummary.restaurant.content)); } if (evSummary.store?.content) { evContainer.appendChild(createSection('Shopping', evSummary.store.content)); } // Only add the tab if the container has children if (evContainer.hasChildNodes()) { createTab('EV Amenities', evContainer, // Passing a Node instead of string evSummary.disclosureText, evSummary.flagContentURI); } } // Safely handle the empty state. if (!firstTabActivated) { const msg = document.createElement('em'); msg.textContent = 'No AI summaries are available for this specific location.'; summaryContent.replaceChildren(msg); aiDisclosure.textContent = ''; } } initMap();
CSS
/* Reuse existing map height */ gmp-map { height: 100%; } html, body { height: 100%; margin: 0; padding: 0; } /* Existing Autocomplete Card Style */ .place-autocomplete-card { background-color: #fff; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px; margin: 10px; padding: 15px; font-family: Roboto, sans-serif; font-size: 1rem; } gmp-place-autocomplete { width: 300px; } /* New: Summary Panel Styles */ .summary-card { background-color: #fff; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px; margin: 10px; padding: 0; /* Padding handled by children */ font-family: Roboto, sans-serif; width: 350px; max-height: 80vh; /* Prevent overflow on small screens */ overflow-y: auto; display: flex; flex-direction: column; } .hidden { display: none; } #place-header { padding: 15px; background-color: #f8f9fa; border-bottom: 1px solid #ddd; } #place-header h2 { margin: 0 0 5px 0; font-size: 1.2rem; } #place-address { margin: 0; color: #555; font-size: 0.9rem; } /* Tab Navigation */ .tab-container { display: flex; border-bottom: 1px solid #ddd; background-color: #fff; } .tab-button { flex: 1; background: none; border: none; padding: 10px; cursor: pointer; font-weight: 500; color: #555; border-bottom: 3px solid transparent; } .tab-button:hover { background-color: #f1f1f1; } .tab-button.active { font-weight: bold; border-bottom: 3px solid #000000; } .tab-button.active:hover { background-color: #ffffff; cursor: default; } /* Content Area */ .content-area { padding: 15px; line-height: 1.5; font-size: 0.95rem; color: #333; } .disclosure-footer { font-size: 0.75rem; color: #666; padding: 10px 15px; border-top: 1px solid #eee; font-style: italic; } .flag-content-link { font-size: 0.75rem; color: #666; padding: 10px 15px; border-top: 1px solid #eee; } /* Reuse existing map height */ gmp-map { height: 100%; } html, body { height: 100%; margin: 0; padding: 0; } /* Existing Autocomplete Card Style */ .place-autocomplete-card { background-color: #fff; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px; margin: 10px; padding: 15px; font-family: Roboto, sans-serif; font-size: 1rem; } gmp-place-autocomplete { width: 300px; } /* New: Summary Panel Styles */ .summary-card { background-color: #fff; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px; margin: 10px; padding: 0; /* Padding handled by children */ font-family: Roboto, sans-serif; width: 350px; max-height: 80vh; /* Prevent overflow on small screens */ overflow-y: auto; display: flex; flex-direction: column; } .hidden { display: none; } #place-header { padding: 15px; background-color: #f8f9fa; border-bottom: 1px solid #ddd; } #place-header h2 { margin: 0 0 5px 0; font-size: 1.2rem; } #place-address { margin: 0; color: #555; font-size: 0.9rem; } /* Tab Navigation */ .tab-container { display: flex; border-bottom: 1px solid #ddd; background-color: #fff; } .tab-button { flex: 1; background: none; border: none; padding: 10px; cursor: pointer; font-weight: 500; color: #555; border-bottom: 3px solid transparent; } .tab-button:hover { background-color: #f1f1f1; } .tab-button.active { font-weight: bold; border-bottom: 3px solid #000000; } .tab-button.active:hover { background-color: #ffffff; cursor: default; } /* Content Area */ .content-area { padding: 15px; line-height: 1.5; font-size: 0.95rem; color: #333; } .disclosure-footer { font-size: 0.75rem; color: #666; padding: 10px 15px; border-top: 1px solid #eee; font-style: italic; } .flag-content-link { font-size: 0.75rem; color: #666; padding: 10px 15px; }
HTML
<html>
<head>
<title>AI Place Summaries</title>
<link rel="stylesheet" type="text/css" href="./style.css" />
<script type="module" src="./index.js"></script>
<!-- prettier-ignore -->
<script>(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})
({key: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "weekly"});</script>
</head>
<body>
<gmp-map center="37.805, -122.425" zoom="14" map-id="DEMO_MAP_ID">
<!-- Search Input Card -->
<div
class="place-autocomplete-card"
slot="control-inline-start-block-start">
<p>Search for a place with AI summaries:</p>
<gmp-place-autocomplete></gmp-place-autocomplete>
</div>
<!-- Summary text panel (initially hidden) -->
<div
id="summary-panel"
class="summary-card hidden"
slot="control-inline-end-block-start">
<div id="place-header">
<h2 id="place-name"></h2>
<p id="place-address"></p>
</div>
<!-- Tabs for toggling summary types -->
<div class="tab-container" id="tab-container"></div>
<!-- Content display area -->
<div id="summary-content" class="content-area"></div>
<!-- Legal/AI Disclosure -->
<div id="ai-disclosure" class="disclosure-footer"></div>
<!-- Flag content link -->
<a id="flag-content-link" class="flag-content-link"></a>
</div>
</gmp-map>
</body>
</html>דוגמה לניסיון
סיכומים מבוססי-AI הם סקירות כלליות של מקום או אזור, שמספקות תובנות מועילות לגבי מקומות ספציפיים, האזור שמסביב למקום וביקורות שקשורות למקום. יש שלושה סוגים שונים של סיכומים מבוססי-AI:
-
סיכום מקום: סקירה כללית קצרה של מקום מסוים, באורך של עד 100 תווים. הסיכום כולל נתונים מסוגים שונים, ומציג תמונה כללית של המקום.
-
סיכום ביקורות: סיכום שנוצר לגבי מקום מסוים על סמך ביקורות משתמשים בלבד.
-
סיכום האזור: סיכום שנוצר לגבי האזור שמסביב למקום, עם הקשר נוסף כולל מוקדי עניין בקרבת מקום. סיכומי אזורים יכולים להיות אחד משני הסוגים הבאים:
-
סיכום השכונה: סקירה כללית של נקודות עניין סמוכות למקומות עם הסוגים
premise,street_addressוכל הסוגים בקטגוריות דיור ולינה. -
סיכום של השירותים בתחנת טעינה לרכב חשמלי: סקירה כללית של מוקדי עניין בקרבת מקומות מסוג
electric_vehicle_charging_station.
-
איך מקבלים סיכומים מבוססי-AI
כדי לאחזר ולהציג סיכומים מבוססי-AI, פועלים לפי השלבים הבאים:
טוענים את הספרייה
Places.const { Place } = await google.maps.importLibrary("places");
קבלת מופע של
Place. בקטע הקוד הבא מוצגת יצירה של מופעPlaceממזהה מקום:const place = new Place("ChIJaYaXFTqq3oARNy537Kb_W_c");
כשקוראים ל-
place.fetchFields(), מציינים את השדות של סוגי הסיכומים שרוצים להשתמש בהם. בדוגמה הבאה, כל שדות הסיכום מבוקשים:await place.fetchFields({ fields: [ 'generativeSummary', 'neighborhoodSummary', 'reviewSummary', 'evChargeAmenitySummary' // Include other fields as needed. ] });
אפשר לאחזר את נתוני הסיכום על ידי גישה למאפיינים
generativeSummary,neighborhoodSummary,reviewSummaryו-evChargeAmenitySummaryבהתאמה. בקטע הקוד הבא מוצגת דוגמה לאחזור הסקירה הכללית מ-generativeSummary.const summaryText = place.generativeSummary.overview;
לא בכל המקומות יש סיכומים מבוססי-AI, לכן חשוב לבדוק אם הנתונים הדרושים קיימים לפני שמציגים אותם למשתמשים. בקטע הקוד הבא נעשה שימוש במשפט if כדי לבדוק אם יש generativeSummary:
if (place.generativeSummary) { overviewText = place.generativeSummary.overview; } else { overviewText = 'No summary is available.'; }
לחלופין, אפשר להשתמש באופרטור nullish כדי לבדוק בקצרה אם יש סיכום:
const overviewText = place.generativeSummary.overview ?? 'No summary is available.';
הצגת הקרדיטים הנדרשים
כל הסיכומים שמבוססים על AI ומוצגים באפליקציה שלכם חייבים לכלול את הקרדיט המתאים בהתאם למדיניות ולסטנדרטים של Google. מידע נוסף מופיע במאמר בנושא מדיניות ושיוכים של Maps JavaScript API.
סיכומים של מקומות
סיכומי מקומות הם סקירות קצרות של עד 100 תווים שמתייחסות למזהה מקום ספציפי, כדי לספק תמונה כללית של המקום. בסיכומים של מקומות יכול להיות שיוצגו מאכלים פופולריים, שירותים או מוצרים שזמינים לרכישה במיקום מסוים:
-
"מסעדה ב-Forum Shops שמגישה מנות גדולות של אוכל איטלקי מסורתי במקום לא רשמי".
-
"מספרה אופנתית שמציעה תספורות וצביעה, וגם פן".
-
"חנות גדולה עם הרבה מוכרים שמציעים מגוון של פריטי עיצוב וינטג', רהיטים ובגדים"
סיכומים של מקומות זמינים לסוגי המקומות שמופיעים בסוגים נתמכים בקטגוריות תרבות, בידור ופנאי, אוכל ושתייה, קניות, שירותים וספורט.
סיכומי מקומות נתמכים בנקודות עניין בשפות ובאזורים הבאים:
| שפה | אזור |
|---|---|
| אנגלית |
הודו ארצות הברית |
בקשת סיכום של מקום
כדי לבקש סיכום גנרטיבי של מקום, צריך לכלול את השדה generativeSummary כשמתקשרים אל fetchFields():
await place.fetchFields({ fields: [ 'generativeSummary', // Include other fields as needed. ], });
משתמשים במאפיין generativeSummary
כדי לאחזר סיכומים של מקומות. קטע הקוד הבא מאחזר את הסקירה הכללית ואת טקסט הגילוי הנאות מgenerativeSummary:
if (place.generativeSummary) { console.log("Place Overview:", place.generativeSummary.overview); console.log("Disclosure:", place.generativeSummary.disclosureText); }
סיכומי ביקורות
סיכומי הביקורות הם סיכומים שנוצרים על סמך ביקורות משתמשים בלבד. סיכומי הביקורות מספקים תובנות ברמה גבוהה ועוזרים למשתמשים לקבל החלטות מושכלות. הם נוצרים על ידי סינתזה של רכיבים מרכזיים בביקורות של משתמשים, כמו מאפייני המקום והסנטימנט של המבקרים.
לדוגמה, סיכום ביקורות על בניין המעבורת בסן פרנסיסקו כולל מידע על מגוון נושאים, כמו אוכל, קניות, נוף ואווירה:
"המבקרים אומרים שהמקום ההיסטורי הזה מציע מגוון רחב של חנויות, מסעדות ושוק איכרים, ורבים משבחים את הנוף של המפרץ והעיר. הם גם מדגישים את האווירה התוססת, את הגישה הנוחה למעבורת ליעדים אחרים ואת ההזדמנות ליהנות מעסקים מקומיים".
סיכומי ביקורות נתמכים בנקודות עניין בשפות ובאזורים הבאים:
| שפה | אזור |
|---|---|
| אנגלית | ארגנטינה, בוליביה, ברזיל, צ'ילה, קולומביה, קוסטה ריקה, הרפובליקה הדומיניקנית, אקוודור, גואטמלה, הודו, יפן, מקסיקו, פרגוואי, פרו, בריטניה, ארצות הברית, אורוגוואי, ונצואלה |
| יפנית | יפן |
| פורטוגזית | ברזיל |
| ספרדית | ארגנטינה, בוליביה, צ'ילה, קולומביה, קוסטה ריקה, הרפובליקה הדומיניקנית, אקוודור, גואטמלה, מקסיקו, פרגוואי, פרו, ארצות הברית, אורוגוואי, ונצואלה |
בקשת סיכום של בדיקה
כדי לבקש סיכום של הביקורות, צריך לכלול את השדה reviewSummary כשמתקשרים אל fetchFields():
await place.fetchFields({ fields: [ 'reviewSummary', // Include other fields as needed. ], });
משתמשים במאפיין
reviewSummary
כדי לאחזר סיכומי ביקורות. כדי לאחזר סיכומי ביקורות, ניגשים למאפיין reviewSummary.text. הקטע הבא מאחזר את הטקסט מ-reviewSummary.
if (place.reviewSummary) { console.log("Place Review Summary:", place.reviewSummary.text); }
סיכומי אזורים
סיכומי אזורים נוצרים עבור האזור שמסביב למקום מסוים. סיכומים של אזורים מספקים הקשר נוסף לגבי מיקום, כולל נקודות עניין בקרבת מקום, כדי שהמשתמשים יוכלו לקבל החלטה מושכלת יותר לגבי המקום שאליו הם רוצים להגיע והפעילויות שהם רוצים לעשות שם. לדוגמה, כשמבקרים בעיר חדשה, אפשר לראות סיכום של השכונה שבה נמצא מלון מסוים כדי לקבל מידע נוסף על האזור:
-
"האזור התוסס הזה בסן פרנסיסקו, שמשלב בין נורת' ביץ' וצ'יינטאון, נמצא מצפון-מערב לרובע הפיננסי וכולל ציוני דרך ספרותיים, אטרקציות תרבותיות ייחודיות ומגוון מסעדות. בין המקומות המפורסמים אפשר למנות את חנות הספרים האייקונית City Lights, את מוזיאון הרכבל המרתק ואת הרחובות התוססים של צ'יינטאון".
אם אתם שוקלים לטעון רכב חשמלי, תוכלו לראות סיכום שנוצר לגבי תחנת טעינה לרכב חשמלי כדי לקבל מידע נוסף על האזור שמסביב:
-
"באזור הזה יש מגוון אפשרויות לסעודה במרחק של 9 דקות הליכה, כולל סטארבקס, סושי ג'ין וסייפווי".
בנוסף לתיאור האזור, התגובה מכילה גם רשימה של מופעי Place
המקומות שמוזכרים בתיאור. אפשר להתקשר למופעים האלה של fetchFields()
Place כדי לבקש פרטים נוספים על כל מקום.
יש שני סוגים של סיכומים של אזורים שמבוססים על AI:
-
סיכום השכונה: סקירה כללית של נקודות עניין בקרבת מקום למקומות עם הסוגים
premise,street_addressוכל הסוגים בקטגוריות דיור ולינה. -
סיכום של השירותים בתחנת טעינה לרכב חשמלי: סקירה כללית של מוקדי עניין בקרבת מקומות מסוג
electric_vehicle_charging_station.
סיכומי אזורים נתמכים בנקודות עניין בשפות ובאזורים הבאים:
| שפה | אזור |
|---|---|
| אנגלית | ארצות הברית |
בקשה לסיכום של השכונה
אפשר לבקש סיכומים של שכונות למקומות עם הסוגים premise,
street_address וכל הסוגים בקטגוריות דיור ואירוח. כדי לבקש סיכום של השכונה, צריך לכלול את השדה neighborhoodSummary כשמתקשרים אל fetchFields():
await place.fetchFields({ fields: [ 'neighborhoodSummary', // Include other fields as needed. ], });
משתמשים במאפיין neighborhoodSummary
כדי לאחזר סיכומים של השכונה. כדי לאחזר סיכומים של שכונות, ניגשים לנכס neighborhoodSummary.content כדי לקבל את הטקסט.
קטע הקוד הבא מאחזר את התוכן של neighborhoodSummary:
if (place.neighborhoodSummary) { console.log("Place Neighborhood Summary:", place.neighborhoodSummary.overview.content); }
בקשת סיכום של מתקני תחנת טעינה לרכב חשמלי
אתם יכולים לבקש סיכומים של שירותים בתחנות טעינה לרכבים חשמליים במקומות עם הסוג
electric_vehicle_charging_station. סיכום המתקנים של תחנת הטעינה לרכבים חשמליים כולל ארבעה סוגים של סיכומים: overview, coffee, restaurant ו-store. לכן, מבנה הנתונים הוא מערך של אובייקטים, שכל אחד מהם מכיל סיכום. כדי לבקש סיכום של שירותים שקשורים לתחנות טעינה לרכב חשמלי, צריך לכלול את השדה evChargeAmenitySummary כשמתקשרים אל fetchFields():
await place.fetchFields({ fields: [ 'evChargeAmenitySummary', // Include other fields as needed. ], });
אפשר להשתמש במאפיין evChargeAmenitySummary
כדי לאחזר סיכומים של שירותים בתחנות טעינה לרכבים חשמליים. כדי לאחזר טקסט מהסיכומים, צריך לגשת למאפיין content של המאפיינים evChargeAmenitySummary.overview, evChargeAmenitySummary.coffee, evChargeAmenitySummary.restaurant ו-evChargeAmenitySummary.store.
קטע הקוד הבא מאחזר את התוכן של evChargeAmenitySummary:
// overview, coffee, restaurant, store. if (place.evChargeAmenitySummary) { console.log("Place EVCS Amenity Summary:", place.evChargeAmenitySummary.overview.content); console.log("Coffee:", place.evChargeAmenitySummary.coffee.content); console.log("Restaurants:", place.evChargeAmenitySummary.restaurant.content); console.log("Stores:", place.evChargeAmenitySummary.store.content); }