Issue description
When I try injecting GoogleMapsAPIWrapper into one of my components, I have to provide the Wrapper either to my NgModule or my NgComponent. This doesn't seem like expected behavior.
If this is an Angular 4 service, you should be able to just import AgmCoreModule and not have to use the providers array in your module.
Steps to reproduce and a minimal demo of the problem
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
constructor(googleMapsAPIWrapper: GoogleMapsAPIWrapper) { //
}
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
AgmCoreModule.forRoot()
],
providers: [ ], //wrong
bootstrap: [AppComponent]
})
export class AppModule { }
The above gives an error.
You need to change to
providers: [ GoogleMapsAPIWrapper ],
bootstrap: [AppComponent]
Expected/desired behavior
You shouldn't have to provide GoogleMapsAPIWrapper
to your Module.
angular2 & angular-google-maps version
angular: 4.1.3
agm/core: 1.0.0-beta.0
Other information
The GoogleMapsAPIWraper gets created when a agm-map instance gets created. This is fully intentional. We maintain one instance per map. If you want to get the instance of the map, you can create a custom component and inject the GoogleMapsAPIWrapper via the constructor. So I'm closing this.
@SebastianM Do you have an example of what your saying as i would like to try this out?
@SebastianM seems it not working.. else i am missing something.. can you please help,
The promise is not getting resolved, line no 25 is not getting executed in app.component.ts in below repo. ( there is no error in console)
https://stackblitz.com/edit/agm-google-maps-api-wrapper-not-working
Most helpful comment
@SebastianM seems it not working.. else i am missing something.. can you please help,
The promise is not getting resolved, line no 25 is not getting executed in app.component.ts in below repo. ( there is no error in console)
https://stackblitz.com/edit/agm-google-maps-api-wrapper-not-working