Description: I followed all the necessary steps to install ngx-leaflet and ngx-leaflet-markercluster to implement a map with marker clustering in my Angular application. Despite the correct installation and configuration, I keep encountering the following error in the console:
ERROR TypeError: L.markerClusterGroup is not a function at _LeafletMarkerClusterDirective.ngOnInit
Environment:
Angular 18 (simple installation without SSR/Hydration)
ngx-leaflet and ngx-leaflet-markercluster installed as described in the documentation.
Problem: When trying to load the map with marker clusters using Angular directives, the errorL.markerClusterGroup is not a function at _LeafletMarkerClusterDirective.ngOnInit is thrown. This prevents the map from rendering correctly with clusters.
Workaround: The only workaround that seems to avoid this issue is to directly initialize the map using an ID for the map container:
Description: I followed all the necessary steps to install ngx-leaflet and ngx-leaflet-markercluster to implement a map with marker clustering in my Angular application. Despite the correct installation and configuration, I keep encountering the following error in the console:
ERROR TypeError: L.markerClusterGroup is not a function at _LeafletMarkerClusterDirective.ngOnInit
Environment:
Code Setup: app.component.ts
app.component.html
Problem: When trying to load the map with marker clusters using Angular directives, the error
L.markerClusterGroup is not a function at _LeafletMarkerClusterDirective.ngOnInit
is thrown. This prevents the map from rendering correctly with clusters.Workaround: The only workaround that seems to avoid this issue is to directly initialize the map using an ID for the map container:
However, this approach bypasses the Angular directives, which is not ideal.
Workaround: Is there a way to use ngx-leaflet-markercluster with Angular directives without encountering this error?