Skip to content

Update Basic Autocomplete to use gmp-map #701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ejhaselden
Copy link
Contributor

No description provided.

@ejhaselden ejhaselden requested a review from willum070 August 12, 2025 23:06
Copy link

snippet-bot bot commented Aug 12, 2025

Here is the summary of changes.

You are about to add 1 region tag.
You are about to delete 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@ejhaselden ejhaselden force-pushed the basic-autocomplete-update branch from 810aeb3 to 41346d0 Compare August 15, 2025 21:42
@ejhaselden ejhaselden force-pushed the basic-autocomplete-update branch from 41346d0 to 5d96c14 Compare August 17, 2025 15:33
)) as google.maps.MapsLibrary;

// Get the initial center directly from the gmp-map element's property.
const center = gmpMapElement.center;

// Set the initial location bias for the autocomplete element.
placeAutocompleteElement.locationBias = center;

// Create the map object with specified options.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Create/Update/

const mapDiv = document.getElementById('map-container') as HTMLElement;
const center: google.maps.LatLngLiteral = { lat: 40.749933, lng: -73.98633 }; // New York City

const gmpMapElement = document.querySelector('gmp-map') as any;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/any/google.maps.MapElement/

ditto others (generally, let's try to avoid any)

const advancedMarkerElement: google.maps.marker.AdvancedMarkerElement = new AdvancedMarkerElement({
map: map,
});
const advancedMarkerElement: google.maps.marker.AdvancedMarkerElement =

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one the anys are gone above, I think you can strip out all the : type type decls?

<gmp-place-details-compact orientation="horizontal">
<gmp-place-details-compact
orientation="horizontal"
style="width: 400px;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be good to comment why inline styles are being used here (esp noting because this element will be moving inside the DOM once JS loads).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants