I am facing an issue with implementing Marker Clusterer in my app. I have successfully installed '@google/markerclusterer' in my project and imported it as shown below. However, a puzzling error keeps popping up: core.js:4002 ERROR TypeError: _google_markerclusterer__WEBPACK_IMPORTED_MODULE_7__ is not a constructor. It's strange because it should be recognized as a constructor. Take a look at the code snippet where the error occurs.
import * as MarkerClusterer from '@google/markerclusterer';
Code snippet within initMap()
for (var i = 0; i < features.length; i++) {
const infowindow = new google.maps.InfoWindow({
content: features[i].content
});
const marker2 = new google.maps.Marker({
position: features[i].position,
icon: icons[features[i].type].icon,
animation: google.maps.Animation.DROP,
map: map
});
marker2.addListener('click', () => {
marker2.setAnimation(google.maps.Animation.BOUNCE);
setTimeout(() => {
marker2.setAnimation(null);
}, 1000);
infowindow.open(map, marker2);
});
const markerCluster = new MarkerClusterer(map, marker2,
{ imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m' });
}