diff --git a/app/mobile-content/maps-config.ts b/app/mobile-content/maps-config.ts new file mode 100644 index 000000000..9f2a3d8e6 --- /dev/null +++ b/app/mobile-content/maps-config.ts @@ -0,0 +1,13 @@ +import { ConfigService } from './../config.service'; +import {Injectable} from '@angular/core'; +import {LazyMapsAPILoaderConfigLiteral} from '@agm/core'; + +@Injectable() +export class MapsConfig implements LazyMapsAPILoaderConfigLiteral { + public apiKey: string; + public libraries: string[]; + constructor(config: ConfigService) { + this.apiKey = config.get('googleMapsApiKey'); + this.libraries = ['places']; + } +} diff --git a/app/mobile-content/mobile-content.module.ts b/app/mobile-content/mobile-content.module.ts index 9b1c89cf7..20a3d13f6 100644 --- a/app/mobile-content/mobile-content.module.ts +++ b/app/mobile-content/mobile-content.module.ts @@ -1,5 +1,6 @@ +import { ConfigService } from './../config.service'; import { RatingTableComponent } from './shared/star-rating-table/star-rating-table.component'; -import { AgmCoreModule } from '@agm/core'; +import { AgmCoreModule, LAZY_MAPS_API_CONFIG } from '@agm/core'; import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; @@ -64,11 +65,12 @@ import { ChangeHistoryDetailedComponent } from './shared/change-history/change-h import { ClickStopPropagationDirective } from '../shared/directives/clickStopPropagation.directive'; +// Used for fetching mapsApiKey +import { MapsConfig } from './maps-config'; + @NgModule({ imports: [ AgmCoreModule.forRoot({ - apiKey: 'AIzaSyAGpVhncb65XwBrV_yWK8RHWcydDsLWCH4', - libraries: ['places'] }), CommonModule, FormsModule, @@ -153,6 +155,11 @@ import { ClickStopPropagationDirective } from '../shared/directives/clickStopPro ChangeHistoryDetailedComponent ], providers: [ + { + provide: LAZY_MAPS_API_CONFIG, + useClass: MapsConfig, + deps: [ConfigService] + }, AchievementApiService, AchievementService, ExhibitService, @@ -166,4 +173,5 @@ import { ClickStopPropagationDirective } from '../shared/directives/clickStopPro ThumbnailService ] }) -export class MobileContentModule {} +export class MobileContentModule { +} diff --git a/typings.d.ts b/typings.d.ts new file mode 100644 index 000000000..09eae4177 --- /dev/null +++ b/typings.d.ts @@ -0,0 +1,4 @@ +declare module "*.json" { + const value: any; + export default value; +} \ No newline at end of file