Place Details (Preview)

If you already have a Place object or place ID, you can call Place.fetchFields to get more details about that place. Use the fields parameter to specify a comma-separated list of one or more place data fields in camel case. Use the returned Place object to get data for the requested fields.

The following example uses a place ID to create a new Place, calls Place.fetchFields requesting the displayName and formattedAddress fields, then logs the resulting data to the console.

TypeScript

async function getPlaceDetails(Place) {
    // Use place ID to create a new Place instance.
    const place = new Place({
        id: 'ChIJN1t_tDeuEmsRUsoyG83frY4',
        requestedLanguage: 'en', // optional
    });

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

    // Show the result
    console.log(place.displayName);
    console.log(place.formattedAddress);
}

JavaScript

async function getPlaceDetails(Place) {
  // Use place ID to create a new Place instance.
  const place = new Place({
    id: "ChIJN1t_tDeuEmsRUsoyG83frY4",
    requestedLanguage: "en", // optional
  });

  // Call fetchFields, passing the desired data fields.
  await place.fetchFields({ fields: ["displayName", "formattedAddress"] });
  // Show the result
  console.log(place.displayName);
  console.log(place.formattedAddress);
}