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

async function initMap(): Promise<void> {
// Asynchronously load required libraries from the Google Maps JS API.
await google.maps.importLibrary('places');
const { AdvancedMarkerElement } = await google.maps.importLibrary('marker') as typeof google.maps.marker;
const { Map, InfoWindow } = await google.maps.importLibrary('maps') as any;
const { AdvancedMarkerElement } = await google.maps.importLibrary('marker') 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.MarkerLibrary/

const { AdvancedMarkerElement } = await google.maps.importLibrary('marker') as typeof google.maps.marker;
const { Map, InfoWindow } = await google.maps.importLibrary('maps') as any;
const { AdvancedMarkerElement } = await google.maps.importLibrary('marker') as any;
const { InfoWindow } = await google.maps.importLibrary('maps') 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.MapsLibrary/

mapTypeControl: false,
streetViewControl: false,
});
const map = await gmpMapElement.innerMap;

Choose a reason for hiding this comment

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

no need for async here I think?

<script>(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})
({key: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "weekly"});</script>
<script>
(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})

Choose a reason for hiding this comment

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

fwiw, I'd generally put <script> tags in the of the html

@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
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