Skip to content

Instantly share code, notes, and snippets.

@transcendr
Created September 27, 2023 14:50
Show Gist options
  • Save transcendr/b3ff52f62014f9743c07715a13e904c7 to your computer and use it in GitHub Desktop.
Save transcendr/b3ff52f62014f9743c07715a13e904c7 to your computer and use it in GitHub Desktop.
this.envService.load().pipe(
first(env => env.googleApiKey != null),
map((env) => {
const currentLang = 'fr'; //this.languageService.getLanguage();
const currentRegion = 'FR'; //this.languageService.getRegion();
const googleApiKey = env.googleApiKey; // 'AIzaSyBU3fyx7thOvVj4K53uNR3N-c9cOUR_62g';
// const src = `https://maps.googleapis.com/maps/api/js?key=${googleApiKey}&libraries=visualization,places&geometry&region=${currentRegion}&language=${currentLang}`;
const script = document.createElement('script');
script.src = `https://maps.googleapis.com/maps/api/js?key=${googleApiKey}&callback=initMap`;
script.type = 'text/javascript';
script.id = 'gmap';
script.async = true;
document.body.appendChild(script);
})
).subscribe();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment