Skip to content
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

Google Maps API loaded multiple times when using Hot Module Reloading #775

Closed
gausie opened this issue Dec 2, 2016 · 9 comments
Closed

Comments

@gausie
Copy link

gausie commented Dec 2, 2016

Issue description
Using HMR, assets are reloaded in place. I get the following error in my console
You have included the Google Maps API multiple times on this page. This may cause unexpected errors.

Steps to reproduce and a minimal demo of the problem
Use angular2-google-maps in a component that is reloaded by HMR.

Current behavior
Reloads the Google Maps API on hot reload

Expected/desired behavior
Keep the old unchanged API instead

angular2 & angular2-google-maps version
Angular2: 2.2.0
A2GM: 0.16.0

@stepanzarubin
Copy link

lazy-maps-api-loader.ts
load()

This function should have a check if API is already loaded.

There is the same issue when script tag was added manually for any other purpose.
I am not sure, but it looks like the author is not actively developing it right now.

@sebholstein
Copy link
Owner

I think maintaining the injector state is not enough in this situation. So we can do better by checking the page.

@szykov
Copy link

szykov commented Feb 27, 2017

I have the same issue with lazy loading. When jump from one module to another it starts raising this issue.

I have no idea how it works but maybe @SkipSelf need to be added when loading api in service?
https://angular.io/docs/ts/latest/api/core/index/SkipSelf-decorator.html

@pdorney
Copy link

pdorney commented Mar 5, 2017

Are there any workarounds for this at the moment?

@asadsahi
Copy link

same issue. Is there a snippet of code which could clarify how to fix this?

Thanks

@mathieugeissler
Copy link

Same here ! you need to check if google api is already loaded maybe with window.google ?

@szykov
Copy link

szykov commented Mar 29, 2017

In case of Lazy Loading look for solution here - #315

@borislemke
Copy link

Anyhow, has anyone ever encountered any problem with this? This error is only raised during development, but it doesn't break anything. It's a nuisance, but it's safe to ignore.

@luiguild
Copy link

any news about it? same problema here with HMR

sebholstein added a commit that referenced this issue Mar 3, 2018
This prevents that we have multiple create script tags for the
google maps api.

Fixes #315
Fixes #775
Fixes #1260
sebholstein added a commit that referenced this issue Mar 3, 2018
This prevents that we have multiple create script tags for the
google maps api.

Fixes #315
Fixes #775
Fixes #1260
sebholstein added a commit that referenced this issue Mar 18, 2018
This prevents that we have multiple create script tags for the
google maps api.

Fixes #315
Fixes #775
Fixes #1260
sebholstein added a commit that referenced this issue Mar 18, 2018
This prevents that we have multiple create script tags for the
google maps api.

Fixes #315
Fixes #775
Fixes #1260
sebholstein added a commit that referenced this issue Mar 18, 2018
This prevents that we have multiple create script tags for the
google maps api.

Fixes #315
Fixes #775
Fixes #1260
sebholstein added a commit that referenced this issue Mar 18, 2018
This prevents that we have multiple create script tags for the
google maps api.

Fixes #315
Fixes #775
Fixes #1260
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants