This commit is contained in:
		
							parent
							
								
									decde7497f
								
							
						
					
					
						commit
						bd167b48d5
					
				
					 1 changed files with 17 additions and 12 deletions
				
			
		| 
						 | 
				
			
			@ -170,23 +170,13 @@ export default class MiOS extends EventEmitter {
 | 
			
		|||
			this.streams.messagingIndexStream = new MessagingIndexStreamManager(this.i);
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		//#region load google maps api
 | 
			
		||||
		(window as any).initGoogleMaps = () => {
 | 
			
		||||
			this.emit('init-google-maps');
 | 
			
		||||
		};
 | 
			
		||||
		const head = document.getElementsByTagName('head')[0];
 | 
			
		||||
		const script = document.createElement('script');
 | 
			
		||||
		script.setAttribute('src', `https://maps.googleapis.com/maps/api/js?key=${googleMapsApiKey}&callback=initGoogleMaps`);
 | 
			
		||||
		script.setAttribute('async', 'true');
 | 
			
		||||
		script.setAttribute('defer', 'true');
 | 
			
		||||
		head.appendChild(script);
 | 
			
		||||
		//#endregion
 | 
			
		||||
 | 
			
		||||
		if (this.debug) {
 | 
			
		||||
			(window as any).os = this;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private googleMapsIniting = false;
 | 
			
		||||
 | 
			
		||||
	public getGoogleMaps() {
 | 
			
		||||
		return new Promise((res, rej) => {
 | 
			
		||||
			if ((window as any).google && (window as any).google.maps) {
 | 
			
		||||
| 
						 | 
				
			
			@ -195,6 +185,21 @@ export default class MiOS extends EventEmitter {
 | 
			
		|||
				this.once('init-google-maps', () => {
 | 
			
		||||
					res((window as any).google.maps);
 | 
			
		||||
				});
 | 
			
		||||
 | 
			
		||||
				//#region load google maps api
 | 
			
		||||
				if (!this.googleMapsIniting) {
 | 
			
		||||
					this.googleMapsIniting = true;
 | 
			
		||||
					(window as any).initGoogleMaps = () => {
 | 
			
		||||
						this.emit('init-google-maps');
 | 
			
		||||
					};
 | 
			
		||||
					const head = document.getElementsByTagName('head')[0];
 | 
			
		||||
					const script = document.createElement('script');
 | 
			
		||||
					script.setAttribute('src', `https://maps.googleapis.com/maps/api/js?key=${googleMapsApiKey}&callback=initGoogleMaps`);
 | 
			
		||||
					script.setAttribute('async', 'true');
 | 
			
		||||
					script.setAttribute('defer', 'true');
 | 
			
		||||
					head.appendChild(script);
 | 
			
		||||
				}
 | 
			
		||||
				//#endregion
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue