-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegionsMap.tsx
More file actions
149 lines (139 loc) · 4.82 KB
/
RegionsMap.tsx
File metadata and controls
149 lines (139 loc) · 4.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import { MapContainer, TileLayer, Marker, Popup } from "react-leaflet"
import "leaflet/dist/leaflet.css"
import "leaflet-gesture-handling/dist/leaflet-gesture-handling.css"
import "leaflet-gesture-handling"
import { Icon } from "leaflet"
import { RegionWithEvents } from "../lib/meetup-scraper"
import { useTranslation } from "react-i18next"
import Image from "next/image"
interface RegionsMapProps {
regions: RegionWithEvents[]
}
declare module "leaflet" {
interface MapOptions {
gestureHandling?: boolean
}
}
const RegionsMap = ({ regions }: RegionsMapProps) => {
const { t } = useTranslation("common", { keyPrefix: "region" })
const customIcon = new Icon({
iconUrl: "/map/icons/javabin-pin.png",
iconSize: [45, 90],
iconAnchor: [21, 52],
popupAnchor: [0, -24],
})
return (
<div
className="relative overflow-hidden rounded-lg"
style={{
width: "100%",
height: "600px",
}}
>
<MapContainer
center={[65.5, 14.5]}
zoom={4.5}
zoomSnap={0.5}
zoomControl={false}
style={{
width: "100%",
height: "100%",
}}
minZoom={4.5}
maxZoom={13}
gestureHandling={true}
scrollWheelZoom={false}
>
<TileLayer
attribution="© <a href='https://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors"
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
{regions.map((region) => (
<Marker
key={region.name}
position={[region.location.lat, region.location.lng]}
icon={customIcon}
>
<Popup className="meetup-popup">
<div className="space-y-2">
<h3 className="text-lg font-bold">javaBin {region.name}</h3>
{region.organizer && (
<div className="mt-2">
<h4 className="mb-2 text-sm font-semibold">
{t("organizer")}:
</h4>
<div className="flex flex-wrap gap-2">
<div
key={region.organizer.id}
className="flex items-center gap-2"
>
<div className="relative h-[34px] w-[34px] shrink-0 overflow-hidden rounded-full border border-solid border-red-400">
<Image
src={region.organizer.photoUrl}
alt={region.organizer.name}
fill
className="object-cover"
sizes="34px"
/>
</div>
<a
href={region.organizer.profileUrl}
target="_blank"
rel="noopener noreferrer"
className="text-sm text-gray-700 hover:underline"
>
{region.organizer.name}
</a>
</div>
</div>
</div>
)}
{region.events && region.events.length > 0 ? (
<div>
<h4 className="text-sm font-semibold">
{t("nextMeetup")}:
</h4>
<div className="text-sm">
<a
href={region.events[0]?.eventUrl}
target="_blank"
rel="noopener noreferrer"
className="hover:underline"
>
{region.events[0]?.name}
</a>
<div className="text-gray-600">
{region.events[0]?.dateTimeFormatted}
{region.events[0]?.venue && (
<div>📍 {region.events[0].venue}</div>
)}
</div>
</div>
</div>
) : (
<p className="text-sm text-gray-600">
{t("noUpcomingEvents")}
</p>
)}
{region.memberCount && (
<div className="text-sm">
👥 {t("memberCount", { count: region.memberCount })}
</div>
)}
<a
href={region?.meetupLink}
target="_blank"
rel="noopener noreferrer"
className="block text-sm text-blue-600 hover:underline"
>
View on Meetup
</a>
</div>
</Popup>
</Marker>
))}
</MapContainer>
</div>
)
}
export default RegionsMap