import { StopDataProvider, Stop } from "../data/StopDataProvider"; import 'leaflet/dist/leaflet.css' import 'react-leaflet-markercluster/styles' import { useEffect, useState } from 'react'; import LineIcon from '../components/LineIcon'; import { Link } from 'react-router'; import { MapContainer, TileLayer, Marker, Popup, useMapEvents } from "react-leaflet"; import MarkerClusterGroup from "react-leaflet-markercluster"; import { Icon, LatLngTuple } from "leaflet"; import { EnhancedLocateControl } from "../controls/LocateControl"; import { useApp } from "../AppContext"; const icon = new Icon({ iconUrl: '/map-pin-icon.png', iconSize: [25, 41], iconAnchor: [12, 41], popupAnchor: [1, -34], shadowSize: [41, 41] }); const sdp = new StopDataProvider(); // Componente auxiliar para detectar cambios en el mapa const MapEventHandler = () => { const { updateMapState } = useApp(); const map = useMapEvents({ moveend: () => { const center = map.getCenter(); const zoom = map.getZoom(); updateMapState([center.lat, center.lng], zoom); } }); return null; }; // Componente principal del mapa export function StopMap() { const [stops, setStops] = useState([]); const { mapState } = useApp(); useEffect(() => { sdp.getStops().then((stops) => { setStops(stops); }); }, []); return ( {stops.map((stop) => ( {stop.name}
{stop.lines.map((line) => ( ))}
))}
); }