-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathEventMap.tsx
More file actions
43 lines (37 loc) · 1.07 KB
/
EventMap.tsx
File metadata and controls
43 lines (37 loc) · 1.07 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
import "leaflet/dist/leaflet.css";
import L from "leaflet";
import { MapContainer, Marker, Popup, TileLayer } from "react-leaflet";
const iconProto = L.Icon.Default.prototype as unknown as {
_getIconUrl?: unknown;
};
delete iconProto._getIconUrl;
L.Icon.Default.mergeOptions({
iconRetinaUrl: "/leaflet/marker-icon-2x.png",
iconUrl: "/leaflet/marker-icon.png",
shadowUrl: "/leaflet/marker-shadow.png",
});
type Props = {
lat: number;
lon: number;
name?: string;
};
export default function EventMap({ lat, lon, name }: Props) {
return (
<div className="mt-6 overflow-hidden rounded-lg border border-gray-600">
<MapContainer
center={[lat, lon]}
zoom={16}
scrollWheelZoom={false}
style={{ height: 320, width: "100%" }}
>
<TileLayer
attribution="© OpenStreetMap contributors"
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
<Marker position={[lat, lon]}>
<Popup>{name ?? "Event location"}</Popup>
</Marker>
</MapContainer>
</div>
);
}