স্থানের বিবরণ (নতুন)

ইউরোপীয় অর্থনৈতিক অঞ্চল (EEA) ডেভেলপাররা

বস্তু রাখুন

স্থান সম্পর্কে তথ্য ধারণকারী Place অবজেক্টটি গতিশীলভাবে টেক্সট অনুসন্ধান, কাছাকাছি অনুসন্ধান এবং স্থান স্বয়ংসম্পূর্ণ দ্বারা ফেরত পাঠানো হয়। আপনি স্থান আইডি বা সংস্থানের নাম থেকেও একটি Place অবজেক্ট তৈরি করতে পারেন (সংস্থানের নাম হল স্থান আইডি যা places/ দিয়ে প্রিফিক্স করা হয়)। নিম্নলিখিত স্নিপেটে স্থান আইডি ব্যবহার করে একটি Place অবজেক্ট তৈরি করা দেখানো হয়েছে:

// Use a place ID to create a new Place instance.
const place = new Place({
    id: 'ChIJyYB_SZVU2YARR-I1Jjf08F0', // San Diego Zoo
});

আপনি একটি প্লেস রিসোর্স নাম থেকে একটি Place অবজেক্টও তৈরি করতে পারেন:

// Use a place resource name to create a new Place instance.
const place = new Place({
  resourceName: 'places/ChIJyYB_SZVU2YARR-I1JRF08F0', // San Diego Zoo
});

আরও তথ্যের জন্য, PlaceOptions দেখুন।

ক্ষেত্রগুলি আনুন

যদি আপনার কাছে একটি বিদ্যমান Place অবজেক্ট, অথবা একটি Place ID বা রিসোর্সের নাম থাকে, তাহলে সেই স্থান সম্পর্কে বিস্তারিত জানতে Place.fetchFields() পদ্ধতি ব্যবহার করুন। ফিরে আসার জন্য স্থানের ডেটা ফিল্ডের একটি কমা দ্বারা পৃথক তালিকা প্রদান করুন; camel ক্ষেত্রে ক্ষেত্রের নাম উল্লেখ করুন। অনুরোধ করা ক্ষেত্রগুলির জন্য ডেটা পেতে ফিরে আসা Place অবজেক্টটি ব্যবহার করুন।

নিচের উদাহরণটি একটি নতুন Place তৈরি করার জন্য একটি place ID ব্যবহার করে, Place.fetchFields() কল করে displayName এবং formattedAddress ক্ষেত্রগুলির জন্য অনুরোধ করে এবং মানচিত্রে একটি মার্কার যোগ করে।

টাইপস্ক্রিপ্ট

async function getPlaceDetails() {
    const { Place } = (await google.maps.importLibrary(
        'places'
    )) as google.maps.PlacesLibrary;
    const { AdvancedMarkerElement } = (await google.maps.importLibrary(
        'marker'
    )) as google.maps.MarkerLibrary;
    // Use place ID to create a new Place instance.
    const place = new Place({
        id: 'ChIJyYB_SZVU2YARR-I1Jjf08F0', // San Diego Zoo
    });

    // Call fetchFields, passing the desired data fields.
    await place.fetchFields({
        fields: [
            'displayName',
            'formattedAddress',
            'location',
            'googleMapsURI',
        ],
    });

    // Add an Advanced Marker
    const marker = new AdvancedMarkerElement({
        map: innerMap,
        position: place.location,
        title: place.displayName,
    });

    // Assemble the info window content.
    const content = document.createElement('div');
    const address = document.createElement('div');
    const placeId = document.createElement('div');
    address.textContent = place.formattedAddress || '';
    placeId.textContent = place.id;
    content.append(placeId, address);

    if (place.googleMapsURI) {
        const link = document.createElement('a');
        link.href = place.googleMapsURI;
        link.target = '_blank';
        link.textContent = 'View Details on Google Maps';
        content.appendChild(link);
    }

    // Display an info window.
    infoWindow.setHeaderContent(place.displayName);
    infoWindow.setContent(content);
    infoWindow.open({
        anchor: marker,
    });
}

জাভাস্ক্রিপ্ট

async function getPlaceDetails() {
    const { Place } = (await google.maps.importLibrary('places'));
    const { AdvancedMarkerElement } = (await google.maps.importLibrary('marker'));
    // Use place ID to create a new Place instance.
    const place = new Place({
        id: 'ChIJyYB_SZVU2YARR-I1Jjf08F0', // San Diego Zoo
    });
    // Call fetchFields, passing the desired data fields.
    await place.fetchFields({
        fields: [
            'displayName',
            'formattedAddress',
            'location',
            'googleMapsURI',
        ],
    });
    // Add an Advanced Marker
    const marker = new AdvancedMarkerElement({
        map: innerMap,
        position: place.location,
        title: place.displayName,
    });
    // Assemble the info window content.
    const content = document.createElement('div');
    const address = document.createElement('div');
    const placeId = document.createElement('div');
    address.textContent = place.formattedAddress || '';
    placeId.textContent = place.id;
    content.append(placeId, address);
    if (place.googleMapsURI) {
        const link = document.createElement('a');
        link.href = place.googleMapsURI;
        link.target = '_blank';
        link.textContent = 'View Details on Google Maps';
        content.appendChild(link);
    }
    // Display an info window.
    infoWindow.setHeaderContent(place.displayName);
    infoWindow.setContent(content);
    infoWindow.open({
        anchor: marker,
    });
}
মনে রাখবেন যে এই ফাংশনের আগে Map এবং Place ঘোষণা করা হয়েছে:
const { Map } = await google.maps.importLibrary("maps");
const { Place } = await google.maps.importLibrary("places");
সম্পূর্ণ উদাহরণটি দেখুন