Markers clusterization, mobile version of map

This commit is contained in:
2025-07-24 17:27:14 +05:00
parent 6a415ec165
commit 1497d6ede3
14 changed files with 463 additions and 89 deletions
+26 -5
View File
@@ -1,18 +1,39 @@
import { AdvancedMarker, Pin } from "@vis.gl/react-google-maps";
import { AdvancedMarker, Pin, useMap } from "@vis.gl/react-google-maps";
import type { Marker } from "@googlemaps/markerclusterer";
import IGMapPoi from "../../types/IGMapPoi";
interface IGMapMarker {
key: string;
location: google.maps.LatLngLiteral;
markerKey: number;
poi: IGMapPoi;
setMarkerRef: (marker: Marker | null, key: string) => void | undefined;
children: React.ReactNode;
}
export default function MapMarker({ key, location, children }: IGMapMarker) {
export default function MapMarker({
markerKey,
poi,
setMarkerRef,
children,
}: IGMapMarker) {
const map = useMap();
return (
<AdvancedMarker key={key} position={location}>
<AdvancedMarker
onClick={() => {
map?.panTo(poi.location);
map?.setZoom(15);
}}
key={markerKey}
position={poi.location}
ref={(marker) =>
!poi.ignoreClusterization && setMarkerRef(marker, markerKey.toString())
}
>
<Pin
background={"transparent"}
glyphColor={"transparent"}
borderColor={"transparent"}
scale={poi.clickableAreaScale || 1}
>
{children}
</Pin>