|
|
|
|
@ -25,8 +25,8 @@ interface ClusterGroup {
|
|
|
|
|
|
|
|
|
|
const createClusterCustomIcon = (cluster: ClusterGroup) => {
|
|
|
|
|
return new DivIcon({
|
|
|
|
|
html: `<span class="flex items-center justify-center w-full h-full bg-primary text-primary-foreground text-xs font-bold rounded-full shadow-md border-2 border-background">${cluster.getChildCount()}</span>`,
|
|
|
|
|
className: "custom-marker-cluster",
|
|
|
|
|
html: `<span class="flex h-8 w-8 items-center justify-center rounded-full border border-border bg-background/95 text-xs font-semibold text-foreground shadow-sm backdrop-blur-sm">${cluster.getChildCount()}</span>`,
|
|
|
|
|
className: "border-none bg-transparent",
|
|
|
|
|
iconSize: L.point(32, 32, true),
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
@ -67,17 +67,41 @@ const UserMemoMap = ({ creator, className }: Props) => {
|
|
|
|
|
const defaultCenter = { lat: 48.8566, lng: 2.3522 };
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className={cn("relative z-0 w-full h-[380px] rounded-xl overflow-hidden border border-border shadow-sm", className)}>
|
|
|
|
|
<div
|
|
|
|
|
className={cn(
|
|
|
|
|
"memo-user-map relative z-0 h-[380px] w-full overflow-hidden rounded-xl border border-border bg-background shadow-sm",
|
|
|
|
|
className,
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
{memosWithLocation.length === 0 && (
|
|
|
|
|
<div className="absolute inset-0 z-[1000] flex items-center justify-center pointer-events-none">
|
|
|
|
|
<div className="flex flex-col items-center gap-1 rounded-2xl border border-border bg-background/70 px-4 py-2 shadow-sm backdrop-blur-sm">
|
|
|
|
|
<MapPinIcon className="h-5 w-5 text-muted-foreground opacity-60" />
|
|
|
|
|
<p className="text-xs font-medium text-muted-foreground">No location data found</p>
|
|
|
|
|
<div className="flex flex-col items-center gap-1.5 rounded-xl border border-border bg-background/92 px-5 py-3 shadow-sm backdrop-blur-sm">
|
|
|
|
|
<MapPinIcon className="h-5 w-5 text-muted-foreground opacity-70" />
|
|
|
|
|
<p className="text-xs font-medium tracking-[0.02em] text-muted-foreground">No location data found</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
<MapContainer center={defaultCenter} zoom={2} className="h-full w-full z-0" scrollWheelZoom attributionControl={false}>
|
|
|
|
|
<div className="pointer-events-none absolute left-4 top-4 z-[950] flex items-start justify-between gap-3 rounded-xl border border-border bg-background/92 px-3 py-2.5 shadow-sm backdrop-blur-sm">
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<span className="grid size-7 place-items-center rounded-full bg-primary/10 text-primary">
|
|
|
|
|
<MapPinIcon className="size-3.5" />
|
|
|
|
|
</span>
|
|
|
|
|
<div className="min-w-0">
|
|
|
|
|
<p className="text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground">Mapped memos</p>
|
|
|
|
|
<p className="text-sm font-semibold text-foreground">{memosWithLocation.length} places pinned</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<MapContainer
|
|
|
|
|
center={defaultCenter}
|
|
|
|
|
zoom={2}
|
|
|
|
|
className="h-full w-full z-0"
|
|
|
|
|
scrollWheelZoom
|
|
|
|
|
zoomControl={false}
|
|
|
|
|
attributionControl={false}
|
|
|
|
|
>
|
|
|
|
|
<ThemedTileLayer />
|
|
|
|
|
<MarkerClusterGroup
|
|
|
|
|
chunkedLoading
|
|
|
|
|
@ -88,10 +112,14 @@ const UserMemoMap = ({ creator, className }: Props) => {
|
|
|
|
|
>
|
|
|
|
|
{memosWithLocation.map((memo) => (
|
|
|
|
|
<Marker key={memo.name} position={[memo.location!.latitude, memo.location!.longitude]} icon={defaultMarkerIcon}>
|
|
|
|
|
<Popup closeButton={false} className="w-48!">
|
|
|
|
|
<div className="flex flex-col p-0.5">
|
|
|
|
|
<div className="flex items-center justify-between border-b border-border pb-1 mb-1">
|
|
|
|
|
<span className="text-[10px] font-medium text-muted-foreground">
|
|
|
|
|
<Popup closeButton={false} className="memo-map-popup w-64!">
|
|
|
|
|
<div className="flex flex-col gap-2.5 p-3">
|
|
|
|
|
<div className="flex items-start justify-between gap-3">
|
|
|
|
|
<div className="space-y-1">
|
|
|
|
|
<span className="inline-flex rounded-full border border-border/70 bg-muted/50 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground">
|
|
|
|
|
Memo
|
|
|
|
|
</span>
|
|
|
|
|
<span className="block text-[11px] font-medium text-muted-foreground">
|
|
|
|
|
{memo.displayTime &&
|
|
|
|
|
timestampDate(memo.displayTime).toLocaleDateString(undefined, {
|
|
|
|
|
year: "numeric",
|
|
|
|
|
@ -99,15 +127,21 @@ const UserMemoMap = ({ creator, className }: Props) => {
|
|
|
|
|
day: "numeric",
|
|
|
|
|
})}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<Link
|
|
|
|
|
to={`/memos/${memo.name.split("/").pop()}`}
|
|
|
|
|
className="flex items-center gap-0.5 text-[10px] text-primary hover:opacity-80"
|
|
|
|
|
className="inline-flex items-center gap-1 rounded-full border border-border bg-background px-2.5 py-1 text-[11px] font-medium text-foreground transition-all hover:border-primary/40 hover:text-primary"
|
|
|
|
|
>
|
|
|
|
|
View
|
|
|
|
|
<ArrowUpRightIcon className="h-3 w-3" />
|
|
|
|
|
Open
|
|
|
|
|
<ArrowUpRightIcon className="h-3.5 w-3.5" />
|
|
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="line-clamp-3 py-0.5 text-xs font-sans leading-snug text-foreground">{memo.snippet || "No content"}</div>
|
|
|
|
|
<div className="space-y-1">
|
|
|
|
|
<div className="line-clamp-3 text-sm leading-snug font-medium text-foreground">{memo.snippet || "No content"}</div>
|
|
|
|
|
<div className="text-[11px] text-muted-foreground">
|
|
|
|
|
{memo.location!.latitude.toFixed(2)}°, {memo.location!.longitude.toFixed(2)}°
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Popup>
|
|
|
|
|
</Marker>
|
|
|
|
|
|