Skip to content

Commit

Permalink
Added VenueCluster type
Browse files Browse the repository at this point in the history
  • Loading branch information
ikorotkaya committed Oct 4, 2023
1 parent c40385c commit 68d02e0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/GoogleMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const MIN_CLUSTER_POINTS = 3;

type Map = google.maps.Map & { zoom: number };

type VenueCluster = ClusterFeature<{ venue: Venue }> & { properties: { venue: Venue } };

export default function GoogleMapsComponent({
userLocation,
onMarkerDragEnd,
Expand All @@ -49,8 +51,8 @@ export default function GoogleMapsComponent({
const mapRef = useRef<Map>();
const [zoom, setZoom] = useState<number>(12);
const [bounds, setBounds] = useState<GeoJSON.BBox>([0, 0, 0, 0]);
const [clusters, setClusters] = useState<ClusterFeature<any>[]>([]);
const [supercluster, setSupercluster] = useState<Supercluster<any>>(new Supercluster({ radius: 75, maxZoom: googleMapOptions.maxZoom, minPoints: MIN_CLUSTER_POINTS }));
const [clusters, setClusters] = useState<VenueCluster[]>([]);
const [supercluster, setSupercluster] = useState<Supercluster>(new Supercluster({ radius: 75, maxZoom: googleMapOptions.maxZoom, minPoints: MIN_CLUSTER_POINTS }));

const updateMapHeight = () => {
const header = document.getElementById("header");
Expand Down Expand Up @@ -170,7 +172,7 @@ export default function GoogleMapsComponent({
if (mapRef.current) {
supercluster.load(formatDataToGeoJsonPoints(venues) as PointFeature<GeoJSON.Feature<GeoJSON.Point>>[]);

setClusters(supercluster.getClusters(bounds, zoom));
setClusters(supercluster.getClusters(bounds, zoom) as VenueCluster[]);
}
}, [venues, bounds, zoom]);

Expand Down

0 comments on commit 68d02e0

Please sign in to comment.