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

stot3 picture stot3  路  3Comments

ChrisDevinePimss picture ChrisDevinePimss  路  3Comments

marcelinobadin picture marcelinobadin  路  3Comments

vamsibassetty08 picture vamsibassetty08  路  3Comments

Subhojit1992 picture Subhojit1992  路  3Comments