import { MapContainer, TileLayer, Marker, Popup } from "react-leaflet"; import L from "leaflet"; import "leaflet/dist/leaflet.css"; import type { Plext } from "../types"; // Fix Leaflet marker icons delete (L.Icon.Default.prototype as any)._getIconUrl; L.Icon.Default.mergeOptions({ iconRetinaUrl: "https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon-2x.png", iconUrl: "https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png", shadowUrl: "https://unpkg.com/leaflet@1.9.4/dist/images/marker-shadow.png", }); interface PlayerMapProps { plexts: Plext[]; } export function PlayerMap({ plexts }: PlayerMapProps) { // Get player locations from plexts const playerLocations = plexts .map((plext) => { const player = plext.markup.find((item) => item.type === "PLAYER"); if (player && player.plain && plext.coordinates && plext.coordinates.coordinates) { return { name: player.plain, team: player.team || "NEUTRAL", coordinates: [plext.coordinates.coordinates[1], plext.coordinates.coordinates[0]] as [number, number], // [lat, lon] eventType: plext.event_type, timestamp: plext.timestamp, }; } return null; }) .filter(Boolean); return (
Team: {location.team}
Event: {location.eventType}
Time: {new Date(location.timestamp).toLocaleString()}