1const loadGoogleMaps = (callback) => {
2 const existingScript = document.getElementById('googleMaps');
3
4 if (!existingScript) {
5 const script = document.createElement('script');
6 script.src = 'https://maps.googleapis.com/maps/api/js?key=<API Key>&libraries=places';
7 script.id = 'googleMaps';
8 document.body.appendChild(script);
9
10 script.onload = () => {
11 if (callback) callback();
12 };
13 }
14
15 if (existingScript && callback) callback();
16};