Cannot read properties of undefined (reading 'getClusterer') - supercluster-googlemaps-adapter

40 Views Asked by At

I am using the library supercluster-googlemaps-adapter and following their official document to create cluster map, but have encountered the following error.

enter image description here

Here is my code :

import { SuperClusterAdapterLoader } from 'supercluster-googlemaps-adapter';

initializeNewMap(
        mapElement: HTMLElement,
        options: google.maps.MapOptions,
        geoData
      ) {
        this.map = new google.maps.Map(mapElement, options);
        this.featureLayer = this.map.getFeatureLayer(
          google.maps.FeatureType.ADMINISTRATIVE_AREA_LEVEL_1
        );
    
        google.maps.event.addListenerOnce(this.map, 'tilesloaded', () => {
          SuperClusterAdapterLoader.getClusterer().then((Clusterer) => {
            if (Clusterer) {
              const clusterer = new Clusterer.Builder(this.map)
                .withRadius(80)
                .withMaxZoom(19)
                .withMinZoom(0)
                .build();
    
              clusterer.load(geoData);
            }
          });
        });
      }
0

There are 0 best solutions below