-
Notifications
You must be signed in to change notification settings - Fork 818
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
Lazy-maps-api-loader error #315
Comments
He @ravindranpandu, do you load the google maps script by yourself anywhere on the page? |
@ravindranpandu hmm, can you show me your |
Hi @SebastianM, To make it easier i have created a sample app, you can see the issue in that ionic app. Thanks in advance |
Try to visit the map page more than once, you will get the issue which i was talking about.
I am not sure why this is happening, please let me know what could be wrong? Thanks |
@ravindranpandu this line is the reason: You create multiple instances of the maps loader when you include the ANGULAR2_GOOGLE_MAPS_PROVIDERS in this place. You have to use ANGULAR2_GOOGLE_MAPS_PROVIDERS in your bootstrap() method. |
@SebastianM i now initialised the ANGULAR2_GOOGLE_MAPS_PROVIDERS in the main app.ts provider, now it works as expected, thanks for your time. |
This seems to also happen when I use angular2-google-maps in a feature module instead of the root app module. Can anyone confirm ? |
In your app.module.ts imports add:
(ofcourse you can remove libraries: ['places']) and then in a shared module add: then the |
Guys, anybody knows how now we work with lazy loading? |
@szykov The solution to using this angular2 component in a lazy loaded submodule is to do what @efstathiosntonas said First, in your main
Then inside your submodule, include it again but without the API key
Now it will lazy load the angular2 maps component and only request the javascript once. I did this using webpack 2 and it works fine. Thanks guys for the good work here. |
@IAMtheIAM thanks. My greetings to @efstathiosntonas too 🥇 |
if you are calling it again somewhere in index file or somewhere else you have to remove it. |
Hi, guys, anybody knows how to find place where I included maps second time? |
Without a code sample it will be difficult to help you @Riasets |
Repo link: https://github.com/Riasets/test |
login: [email protected] |
@Riasets I cloned and ran your app, looks very good. For me, after login the map immediately loads, and if i change to any other page, map also loads fine. I don't see any problem, can you clarirfy more? |
@IAMtheIAM Login page was first and map page was secaond. In this case map loads. But if you already authorized and try going to /home page, for example, map will not loads. Or try to reload page with map, it will not loads too. And also you can see at dev tools 2 the same scripts with google maps |
Hi @SebastianM ,
I am using angular2-google-maps in ionic2/angular2 in which we need the map only in one page and it works fine too, but every consecutive visit to the same page gives me an error.
Please let me know if i am missing something.
Thanks
The text was updated successfully, but these errors were encountered: