-
Notifications
You must be signed in to change notification settings - Fork 822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
You have included the Google Maps API multiple times on this page #692
Comments
@escarabin the problem is that you import the module in a child module of your app. You have to import it inside your root module of the app. Closing this as this is no bug. Feel free to reopen. Thx! |
hey @SebastianM! Thanks for the advice but I am still facing the issue.
Now, when I import AgmCoreModule in my app.module.ts, I see an error saying that What should I do then? PS: I do not have the ability to re-open the issue |
anyone? :( I am quite stuck with it right now |
@escarabin i had similar problem. Try this. You need to import maps in the root application module, so you do something like this:
But then if you want to use maps in a component that does not belong to this module, go to that module and do this:
|
To add why I think this works, is because you need to register the thing at the root of your application (so that google stuff is initialised with your key). But you are using Hope that solves the issue |
Thank you so much for the effort @EddyP23 but unfortunately I still see the error...is it really working on your side using angular2-google-maps@0.15.0? It's very weird. The problem is not the error itself but it also causes a bunch of completely random bugs on the page... Also, you are talking about |
@escarabin Yes, I am using version 0.15.0. By smth smth I do mean any
What error are you seeing now? I do believe this setup should work. Could you share more code? |
I still see "You have included the Google Maps API multiple times on this page" error. My HTML looks like this:
Here is my child module:
and my app.module.ts @NgModule:
|
Hm.. That is weird. Are you sure you don't have script tags importing google maps anywhere (e.g. in
I would also go through all the usages of |
I'm also having this issue. I've added the AgmCoreModule.forRoot({...}) in the app.module for my components, and I've checked for multiple google api calls. |
I am also having this issue. I've also added the AgmCoreModule.forRoot({...}) in the app.module for my components, and I've also checked for multiple google api calls. |
Ok my mistake, if it helps anyone else here--try deleting your old script tag rather than commenting it out. For some reason, commenting it in the template was not removing it. |
@EddyP23 , What can i do if im using skd autocomplete and agm maps? |
Unfortunately I cannot |
Below is my fairly nasty hack to allow for a) older dependencies that assume the api is included statically via a hardcoded Implement the Overrides
Wire it up in app.module
|
Check in lazy loader if google maps script was loaded and maps are initialized in window. Fixes #692
I have been trying to resolve this issue from many days finally i arrived at the solution by comparing all the module file in the project. |
I was able to resolve the problem in the escenario that @escarabin describes overriding the module.
And importing the module in the shared module
And in the lazy loaded module
|
Thank you so much:).
…On Mon, Mar 19, 2018 at 7:03 PM, Juliete ***@***.***> wrote:
I was able to resolve the problem in the escenario that @escarabin
<https://github.com/escarabin> describes overriding the module.
import { ModuleWithProviders, Inject, Optional, NgModule } from ***@***.***/core';
import { CommonModule } from ***@***.***/common';
import { AgmCoreModule, LAZY_MAPS_API_CONFIG, MapsAPILoader } from ***@***.***/core';
import { LazyMapsAPILoader, LazyMapsAPILoaderConfigLiteral } from ***@***.***/core/services/maps-api-loader/lazy-maps-api-loader';
import { WindowRef, DocumentRef, BROWSER_GLOBALS_PROVIDERS } from ***@***.***/core/utils/browser-globals';
import { coreDirectives } from ***@***.***/core/core.module';
@NgModule({ imports: [CommonModule, AgmCoreModule], exports: [AgmCoreModule]})
export class AgmOverrideModule {
static forRoot(lazyMapsAPILoaderConfig?: LazyMapsAPILoaderConfigLiteral): ModuleWithProviders {
return {
ngModule: AgmOverrideModule, providers: [BROWSER_GLOBALS_PROVIDERS, { provide: MapsAPILoader, useClass: ApiLoader },
{ provide: LAZY_MAPS_API_CONFIG, useValue: lazyMapsAPILoaderConfig } ]}
}
}
export class ApiLoader extends LazyMapsAPILoader {
private static cargado: boolean;
constructor( @optional() @Inject(LAZY_MAPS_API_CONFIG) config: any, @Inject(WindowRef) w: WindowRef, @Inject(DocumentRef) d: DocumentRef) {
super(config, w, d);
}
load(): Promise<void> {
if (ApiLoader.cargado) {
return new Promise<void>(resolve => resolve());
} else {
return new Promise<void>((resolve, reject) => {
super.load()
.then(() => {
ApiLoader.cargado = true;
resolve();
})
.catch(err => {
reject(err);
});
});
}
}
}
And importing the module in the shared module
AgmOverrideModule.forRoot({
apiKey: environment.claveMaps
}),
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#692 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AiXUoVhigXAsP1d3tYQsPwK8UP_T-lfXks5tf7OkgaJpZM4KMHK6>
.
|
I also have the problem with version 1.0.0-beta.5 of the library. I investigated the problem and it doesn't occur in every case. Here is the context, I have the main module that uses
and a lazy module that uses
I can reproduce the problem when first going to a page linked to the root module and then going to a page of the lay module. If I go directly to the page whithin the lazy module, I don't have the problem... I investigated a bit the problem and i appeared that the
Do you have an idea of how to fix this problem? |
I know this issue happened to others but I am pretty stuck with it since days, can't find any solution.
Here is my @NgModule:
Here is my HTML:
And here is a screenshot of what I have inside my HTML head tag:
So it looks like it is really including the API twice but I don't know why or how.
The text was updated successfully, but these errors were encountered: