Skip to content

Commit

Permalink
fix: Moves Place class declaration to avoid confusing pattern.
Browse files Browse the repository at this point in the history
Just a simple small change to move the Place class declaration into the function that's using it, to avoid using the pattern of passing Place as a function parameter.
  • Loading branch information
willum070 authored Oct 31, 2024
1 parent d0181ae commit cb7e374
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions samples/place-class/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ let centerCoordinates = { lat: 37.4161493, lng: -122.0812166 };

async function initMap() {
const { Map } = await google.maps.importLibrary("maps") as google.maps.MapsLibrary;
const { Place } = await google.maps.importLibrary("places") as google.maps.PlacesLibrary;

map = new Map(document.getElementById('map') as HTMLElement, {
center: centerCoordinates,
Expand All @@ -20,11 +19,12 @@ async function initMap() {
// [END_EXCLUDE]
});

getPlaceDetails(Place);
getPlaceDetails();
}

// [START maps_place_class_fetchfields]
async function getPlaceDetails(Place) {
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({
Expand All @@ -50,4 +50,4 @@ async function getPlaceDetails(Place) {

initMap();
// [END maps_place_class]
export { };
export { };

0 comments on commit cb7e374

Please sign in to comment.