summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-03-06 07:39:47 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-03-06 07:39:47 +0900
commitbd167b48d5b521fad135f40f8cff080a9e7ffa18 (patch)
tree053d7881f38ade4cdc74d8a60e4dc5aaaadcd7d7 /src
parentv3990 (diff)
downloadsharkey-bd167b48d5b521fad135f40f8cff080a9e7ffa18.tar.gz
sharkey-bd167b48d5b521fad135f40f8cff080a9e7ffa18.tar.bz2
sharkey-bd167b48d5b521fad135f40f8cff080a9e7ffa18.zip
#1189
Diffstat (limited to 'src')
-rw-r--r--src/web/app/common/mios.ts29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/web/app/common/mios.ts b/src/web/app/common/mios.ts
index bf04588bcc..da1d9746a1 100644
--- a/src/web/app/common/mios.ts
+++ b/src/web/app/common/mios.ts
@@ -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
}
});
}