Clusters are breaking the universal app
See original GitHub issueIssue description
Just importing the cluster module is breaking the app.
Steps to reproduce and a minimal demo of the problem
I have a map where all its markers are under a cluster. The map is wrapped into a conditional so it renders only on client (not on the server) because there are known issues. However, it still breaks the server side rendering because it tries to access window
at some point. This probably happens during module initialization, since the component itself never got instantiated.
Current behavior
Apps using cluster cannot be used in a server side app.
Expected/desired behavior
Apps should not break.
angular & angular-google-maps version
@angular/*
at 5.0.0@agm/core
at 1.0.0-beta.2
Other information
I’m looking for a workaround ATM but, of course, would be nice if users having a Universal app do not have to do anything. We should at least wrap all code with isPlatformBrowser
and just list that as a caveat for now, until we figure out how to render maps on the server, if it’s even possible.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:30 (4 by maintainers)
Top GitHub Comments
I forked
js-marker-clusterer
project and made the fix. It prevents initializationMarkerClusterer
when window is not defined (on server side rendering). So marker clusterer works correctly in both cases now.It’s published in npm. https://www.npmjs.com/package/js-marker-clusterer-universal
js-marker-clusterer
dependency should be replaced byjs-marker-clusterer-universal
to take effect.@AoschkA I’m still using the workaround as mentioned in my earlier comment. You can find my example here:
https://github.com/cmddavid/js-marker-clusterer.git