diff --git a/src/config.ts b/src/config.ts index 3ffefe278b..e327cb0ba5 100644 --- a/src/config.ts +++ b/src/config.ts @@ -89,6 +89,8 @@ type Source = { public_key: string; private_key: string; }; + + google_maps_api_key: string; }; /** diff --git a/src/web/app/common/mios.ts b/src/web/app/common/mios.ts index c5f0d1d4dc..bf04588bcc 100644 --- a/src/web/app/common/mios.ts +++ b/src/web/app/common/mios.ts @@ -1,7 +1,7 @@ import Vue from 'vue'; import { EventEmitter } from 'eventemitter3'; -import { host, apiUrl, swPublickey, version, lang } from '../config'; +import { host, apiUrl, swPublickey, version, lang, googleMapsApiKey } from '../config'; import Progress from './scripts/loading'; import HomeStreamManager from './scripts/streaming/home-stream-manager'; import DriveStreamManager from './scripts/streaming/drive-stream-manager'; @@ -170,8 +170,33 @@ export default class MiOS extends EventEmitter { this.streams.messagingIndexStream = new MessagingIndexStreamManager(this.i); }); - // TODO: this global export is for debugging. so disable this if production build - (window as any).os = this; + //#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; + } + } + + public getGoogleMaps() { + return new Promise((res, rej) => { + if ((window as any).google && (window as any).google.maps) { + res((window as any).google.maps); + } else { + this.once('init-google-maps', () => { + res((window as any).google.maps); + }); + } + }); } public log(...args) { diff --git a/src/web/app/config.ts b/src/web/app/config.ts index b51279192c..24158c3aed 100644 --- a/src/web/app/config.ts +++ b/src/web/app/config.ts @@ -13,6 +13,7 @@ declare const _THEME_COLOR_: string; declare const _COPYRIGHT_: string; declare const _VERSION_: string; declare const _LICENSE_: string; +declare const _GOOGLE_MAPS_API_KEY_: string; export const host = _HOST_; export const url = _URL_; @@ -29,3 +30,4 @@ export const themeColor = _THEME_COLOR_; export const copyright = _COPYRIGHT_; export const version = _VERSION_; export const license = _LICENSE_; +export const googleMapsApiKey = _GOOGLE_MAPS_API_KEY_; diff --git a/src/web/app/desktop/views/components/post-detail.vue b/src/web/app/desktop/views/components/post-detail.vue index 32d401351d..fdf97282b3 100644 --- a/src/web/app/desktop/views/components/post-detail.vue +++ b/src/web/app/desktop/views/components/post-detail.vue @@ -39,14 +39,16 @@
-
+
{{ tag }}
+ %fa:map-marker-alt% 位置情報 +