Angular-google-maps: agm api key from server after login

Created on 31 Oct 2018  路  2Comments  路  Source: SebastianM/angular-google-maps

Hi. I'm using angular 4, now i have a problem with my app due to api key initialization in AppModule. So i have agm in one of component. My google api key stored in secured server endpoint. So for
getting api key i have to be logged in. Any ideas how to upload api key only after login?

stale

Most helpful comment

Hi RaAleks,

I had a similar Problem. A way to change the API Key after your login may be;

  • import the NgModule: AgmCoreModule.forRoot({ apiKey: 'NOPE' })
  • in the service, where you read your key from the endpoint you can inject the config via:
  • constructor(@Optional() @Inject(LAZY_MAPS_API_CONFIG) config: any = null) and change it:
  • if (config) config.apiKey = ReadKey();

All 2 comments

Hi RaAleks,

I had a similar Problem. A way to change the API Key after your login may be;

  • import the NgModule: AgmCoreModule.forRoot({ apiKey: 'NOPE' })
  • in the service, where you read your key from the endpoint you can inject the config via:
  • constructor(@Optional() @Inject(LAZY_MAPS_API_CONFIG) config: any = null) and change it:
  • if (config) config.apiKey = ReadKey();

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nthonymiller picture nthonymiller  路  4Comments

shedar picture shedar  路  4Comments

gizm0bill picture gizm0bill  路  4Comments

DeveloperAdd007 picture DeveloperAdd007  路  3Comments

ChrisDevinePimss picture ChrisDevinePimss  路  3Comments