ملخّصات مستندة إلى الذكاء الاصطناعي

الاطّلاع على الرمز المصدر للمثال الكامل

ابحث عن أماكن للاطّلاع على الملخّصات المستندة إلى الذكاء الاصطناعي. إليك بعض عمليات البحث المقترَحة:

  • "فندق" لملخّصات الأحياء
  • "محطة شحن للمركبات الكهربائية" لملخّصات وسائل الراحة في محطات شحن المركبات الكهربائية
  • أي مطعم أو نشاط تجاري للحصول على ملخّصات عن الأماكن وملخص المراجعات

TypeScript

// 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'
) as HTMLAnchorElement;

let innerMap: google.maps.Map;
let marker: google.maps.marker.AdvancedMarkerElement;

async function init(): Promise<void> {
    // Request needed libraries.
    const [{ AdvancedMarkerElement }] = 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.
    innerMap.addListener('bounds_changed', () => {
        placeAutocomplete.locationRestriction = innerMap.getBounds()!;
    });

    // Create the marker.
    marker = new AdvancedMarkerElement({
        map: innerMap,
    });

    // Handle selection of an autocomplete result.
    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 | null,
        flagUrl: string | null
    ) => {
        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) ---
    if (place.generativeSummary?.overview) {
        createTab(
            'Overview',
            place.generativeSummary.overview,
            place.generativeSummary.disclosureText,
            place.generativeSummary.flagContentURI
        );
    }

    // --- 2. Review Summary ---
    if (place.reviewSummary?.text) {
        createTab(
            'Reviews',
            place.reviewSummary.text,
            place.reviewSummary.disclosureText,
            place.reviewSummary.flagContentURI
        );
    }

    // --- 3. Neighborhood Summary ---
    if (place.neighborhoodSummary?.overview?.content) {
        createTab(
            'Neighborhood',
            place.neighborhoodSummary.overview.content,
            place.neighborhoodSummary.disclosureText,
            place.neighborhoodSummary.flagContentURI
        );
    }

    // --- 4. EV Amenity Summary (uses content blocks)) ---
    if (place.evChargeAmenitySummary) {
        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 = '';
    }
}

void init();

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 init() {
    // Request needed libraries.
    const [{ AdvancedMarkerElement }] = 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.
    innerMap.addListener('bounds_changed', () => {
        placeAutocomplete.locationRestriction = innerMap.getBounds();
    });

    // Create the marker.
    marker = new AdvancedMarkerElement({
        map: innerMap,
    });

    // Handle selection of an autocomplete result.
    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) ---
    if (place.generativeSummary?.overview) {
        createTab(
            'Overview',
            place.generativeSummary.overview,
            place.generativeSummary.disclosureText,
            place.generativeSummary.flagContentURI
        );
    }

    // --- 2. Review Summary ---
    if (place.reviewSummary?.text) {
        createTab(
            'Reviews',
            place.reviewSummary.text,
            place.reviewSummary.disclosureText,
            place.reviewSummary.flagContentURI
        );
    }

    // --- 3. Neighborhood Summary ---
    if (place.neighborhoodSummary?.overview?.content) {
        createTab(
            'Neighborhood',
            place.neighborhoodSummary.overview.content,
            place.neighborhoodSummary.disclosureText,
            place.neighborhoodSummary.flagContentURI
        );
    }

    // --- 4. EV Amenity Summary (uses content blocks)) ---
    if (place.evChargeAmenitySummary) {
        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 = '';
    }
}

void init();

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: 2px;
    font-family: Roboto, sans-serif;
    font-size: 1rem;
}

gmp-place-autocomplete {
    width: 330px;
}

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

HTML

<html>
    <head>
        <title>AI Place Summaries</title>
        <link rel="stylesheet" type="text/css" href="./style.css" />
        <script type="module" src="./index.js"></script>
        <script>
            // prettier-ignore
            (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: "GOOGLE_MAPS_API_KEY"
            });
        </script>
    </head>
    <body>
        <gmp-map center="37.80, -122.425" zoom="14" map-id="DEMO_MAP_ID">
            <!-- Search Input Card -->
            <div
                class="place-autocomplete-card"
                slot="control-inline-start-block-start">
                <gmp-place-autocomplete
                    placeholder="Find places with AI summaries"></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>

الملخّصات المستندة إلى الذكاء الاصطناعي هي نظرة عامة على مكان أو منطقة معيّنة تقدّم إحصاءات مفيدة حول أماكن محدّدة والمنطقة المحيطة بمكان معيّن والمراجعات المرتبطة به. هناك ثلاثة أنواع مختلفة من الملخّصات المستندة إلى الذكاء الاصطناعي:

  • ملخّص المكان: نظرة عامة موجزة من 100 حرف خاصة برقم تعريف مكان معيّن، تجمع العديد من أنواع البيانات المختلفة في لقطة عالية المستوى للمكان.

  • ملخّص المراجعات: ملخّص يتم إنشاؤه لمكان معيّن استنادًا إلى مراجعات المستخدمين فقط.

  • ملخّص المنطقة: ملخّص يتم إنشاؤه للمنطقة المحيطة بمكان معيّن، ويوفّر سياقًا إضافيًا يشمل المعالم القريبة. يمكن أن تكون ملخّصات المناطق من أحد النوعَين التاليَين:

    • ملخّص عن الحيّ: نظرة عامة شاملة على نقاط الاهتمام القريبة للأماكن التي تتضمّن الأنواع premise وstreet_address وجميع الأنواع في فئتَي الإسكان والإقامة.

    • ملخّص وسائل الراحة في محطة شحن المركبات الكهربائية: نظرة عامة شاملة على نقاط الاهتمام القريبة للأماكن من النوع electric_vehicle_charging_station

استرداد الملخّصات المستندة إلى الذكاء الاصطناعي

لاسترداد الملخّصات المستنِدة إلى الذكاء الاصطناعي وعرضها، اتّبِع الخطوات التالية:

  1. حمِّل مكتبة Places.

    const { Place } = await google.maps.importLibrary("places");
  2. احصل على مثيل Place. يعرض المقتطف التالي كيفية إنشاء مثيل Place من رقم تعريف مكان:

    const place = new Place("ChIJaYaXFTqq3oARNy537Kb_W_c");
  3. في طلبك إلى place.fetchFields()، حدِّد الحقول لأنواع الملخّصات التي تريد استخدامها. في المقتطف التالي، يتم طلب جميع حقول الملخّص:

    await place.fetchFields({
      fields: [
        'generativeSummary',
        'neighborhoodSummary',
        'reviewSummary',
        'evChargeAmenitySummary'
        // Include other fields as needed.
      ]
    });
              
  4. استردّ بيانات الملخّص من خلال الوصول إلى السمات generativeSummary وneighborhoodSummary وreviewSummary وevChargeAmenitySummary على التوالي. يوضّح المقتطف التالي كيفية استرداد النظرة العامة من generativeSummary.

    const summaryText = place.generativeSummary.overview;
            

بما أنّ بعض الأماكن لا تتوفّر لها ملخّصات مستندة إلى الذكاء الاصطناعي، تأكَّد من توفّر البيانات المطلوبة قبل عرضها للمستخدمين. يستخدم المقتطف التالي عبارة if للتحقّق من وجود generativeSummary:

if (place.generativeSummary) {
  overviewText = place.generativeSummary.overview;
} else {
  overviewText = 'No summary is available.';
}
    

بدلاً من ذلك، يمكنك استخدام عامل تشغيل فارغ للتحقّق بإيجاز من وجود ملخّص:

const overviewText = place.generativeSummary.overview ?? 'No summary is available.';
    

عرض معلومات تحديد المصدر المطلوبة

يجب أن تكون جميع الملخّصات المستندة إلى الذكاء الاصطناعي والمعروضة في تطبيقك مصحوبةً بمصدر الاقتباس المناسب وفقًا لسياسات 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);
}
    

ملخّصات المراجعات

ملخّصات المراجعات هي ملخّصات يتم إنشاؤها استنادًا إلى مراجعات المستخدمين فقط. من خلال تجميع العناصر الرئيسية لمراجعات المستخدمين، مثل سمات المكان ومشاعر المراجعين، تقدّم ملخّصات المراجعات إحصاءات عالية المستوى وتساعد المستخدمين في اتّخاذ قرارات مدروسة.

على سبيل المثال، يتضمّن ملخّص المراجعات لمبنى Ferry Building في سان فرانسيسكو معلومات تتراوح بين الطعام والتسوّق والمناظر والأجواء:

"يقول الزوّار إنّ هذا المعلم التاريخي يضم مجموعة متنوعة من المتاجر والمطاعم وسوقًا للمزارعين، وقد أشاد الكثيرون بالإطلالات على الخليج والمدينة. ويشيرون أيضًا إلى الأجواء النابضة بالحياة، وسهولة الوصول إلى الوجهات الأخرى باستخدام العبّارات، وفرصة الاستمتاع بالأنشطة التجارية المحلية".

تتوفّر ملخّصات المراجعات للأماكن المهمة باللغات والمناطق التالية:

اللغة المنطقة
الإنجليزية الأرجنتين وأوروغواي والإكوادور والبرازيل والمكسيك والمملكة المتحدة والهند والولايات المتحدة واليابان وباراغواي وبوليفيا وبيرو وتشيلي وجمهورية الدومينيكان وغواتيمالا وفنزويلا وكوستاريكا وكولومبيا
اليابانية اليابان
البرتغالية البرازيل
الإسبانية الأرجنتين وبوليفيا وتشيلي وكولومبيا وكوستاريكا وجمهورية الدومينيكان والإكوادور وغواتيمالا والمكسيك وباراغواي وبيرو والولايات المتحدة وأوروغواي وفنزويلا

طلب ملخّص المراجعات

لطلب ملخّص المراجعات، يجب تضمين الحقل 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);
}
  

ملخّصات عن المناطق

يتم إنشاء ملخّصات للمنطقة المحيطة بمكان معيّن. توفّر ملخّصات المناطق سياقًا إضافيًا عن الموقع الجغرافي، بما في ذلك المعالم القريبة، ليتمكّن المستخدمون من اتّخاذ قرار مدروس أكثر بشأن الأماكن التي يمكنهم زيارتها والأنشطة التي يمكنهم ممارستها عند الوصول إلى وجهتهم. على سبيل المثال، عند زيارة مدينة جديدة، يمكنك الاطّلاع على ملخّص تم إنشاؤه عن الحي الذي يقع فيه الفندق لمعرفة المزيد عن المنطقة المحيطة:

  • "تقع هذه المنطقة النابضة بالحياة في سان فرانسيسكو، وتجمع بين "نورث بيتش" و"الحي الصيني"، وتقع شمال غرب "المنطقة المالية" وتضم معالم أدبية ومعالم ثقافية فريدة ومطاعم متنوعة. تشمل المواقع البارزة مكتبة "سيتي لايتس" الشهيرة و"متحف التلفريك" الرائع وشوارع "الحي الصيني" الصاخبة".

إذا كنت تفكّر في شحن مركبة كهربائية، يمكنك الاطّلاع على ملخّص تم إنشاؤه لمحطة شحن مركبات كهربائية لمعرفة المزيد عن المنطقة المحيطة:

  • "توفّر هذه المنطقة مجموعة من خيارات تناول الطعام على بُعد 9 دقائق سيرًا على الأقدام، بما في ذلك Starbucks وSushi Jin وSafeway".

بالإضافة إلى وصف المنطقة، تحتوي الاستجابة أيضًا على قائمة بمثيلات Place للأماكن المُشار إليها في الوصف. يمكنك استدعاء fetchFields() في مثيلات Place هذه لطلب مزيد من التفاصيل لكل مكان.

هناك نوعان من الملخّصات المستندة إلى الذكاء الاصطناعي:

  • ملخّص عن الحي: نظرة عامة شاملة على نقاط الاهتمام القريبة للأماكن التي تتضمّن الأنواع 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);
}