// Initialize with your Google Maps API key
const placeData = new PlaceData("YOUR_API_KEY");
// Get place data from a Google Maps URL
const placeFromUrl = await placeData.getFromUrl(
"https://www.google.com/maps/place/...",
true
);
// Get place data from a feature ID
const placeFromFeatureId = await placeData.getFromFeatureId(
"0x12345:0x67890",
false
);
// Get place data from a Google Place ID
const placeFromPlaceId = await placeData.getFromPlaceId("ChIJ...ABCD", true);
// Get place data using a search query
const placeFromQuery = await placeData.getFromQuery("The White House", false);
`
$3
#### Constructor
apiKey - string: Your Google Maps API key required for some operations.
> [!NOTE]
> The API key is used to call an endpoint which falls under the SKU: Places API Text Search Essentials (IDs Only) which has unlimited free usage (Source: Google, Archived). The API key only required if you will use the method getFromQuery.
#### Methods
1. getFromUrl(url, clean)
- url - string: A Google Maps place URL as explained here - clean - boolean: Whether to return a cleaned output. Defaults to false.
2. getFromFeatureId(featureId, clean)
- featureId - string: The feature ID of a place (format: "0x...:0x...").
- clean - boolean: Whether to return a cleaned output. Defaults to false.
3. getFromPlaceId(placeId, clean)
- placeId - string: The Google Place ID.
- clean - boolean: Whether to return a cleaned output. Defaults to false.
4. getFromQuery(query, clean) - query - string: Search query to find the place.
- clean - boolean: Whether to return a cleaned output. Defaults to false.