Angular-google-maps: How to use api key with angular2-google-maps.

Created on 1 Mar 2016  路  7Comments  路  Source: SebastianM/angular-google-maps

Thanks for a great repo. Can you say me how to use API key with angular2-google-maps.

MapsAPILoader discussion / question

Most helpful comment

Hi @santhoshreddy31. Here's an example:

import {provide} from 'angular2/core';
import {ANGULAR2_GOOGLE_MAPS_PROVIDERS, LazyMapsAPILoaderConfig} from 'angular2-google-maps/core';

bootstrap(AppComponent, [
  ANGULAR2_GOOGLE_MAPS_PROVIDERS,
  provide(LazyMapsAPILoaderConfig, {useFactory: () => {
    let config = new LazyMapsAPILoaderConfig();
    config.apiKey = 'mykey';
    return config;
  }})
])

There are also several more options you can configure: https://angular-maps.com/docs/api/latest/ts/core/LazyMapsAPILoaderConfig-class.html

I close this issue now. Feel free to reopen or comment if you have further questions.

All 7 comments

Hi @santhoshreddy31. Here's an example:

import {provide} from 'angular2/core';
import {ANGULAR2_GOOGLE_MAPS_PROVIDERS, LazyMapsAPILoaderConfig} from 'angular2-google-maps/core';

bootstrap(AppComponent, [
  ANGULAR2_GOOGLE_MAPS_PROVIDERS,
  provide(LazyMapsAPILoaderConfig, {useFactory: () => {
    let config = new LazyMapsAPILoaderConfig();
    config.apiKey = 'mykey';
    return config;
  }})
])

There are also several more options you can configure: https://angular-maps.com/docs/api/latest/ts/core/LazyMapsAPILoaderConfig-class.html

I close this issue now. Feel free to reopen or comment if you have further questions.

Still getting the error after using the LazyMapsAPILoader and the versions 3.18,3.19,3.23,3.24

Any help?

Hi @SebastianM I entered mykey like how you showed above. I don't have any errors, but map is not loading. Any idea why?

same here @bkshashi30 did you fix it?

how to use API key in angular 2.0?

@paruvellyvishwanath You need to import the module along with the information about your API key using forRoot static method of AgmCoreModule. You can see the example in the docs.

Just use api key in your index.html file.
Example:
Its solved my problem. for Error - MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error #537

Was this page helpful?
0 / 5 - 0 ratings

Related issues

n1t3w0lf picture n1t3w0lf  路  3Comments

DeveloperAdd007 picture DeveloperAdd007  路  3Comments

gnujeremie picture gnujeremie  路  3Comments

dineshkumar20 picture dineshkumar20  路  3Comments

mensch picture mensch  路  3Comments