display multiple kml files on same leaflet map component

This commit is contained in:
2025-05-12 19:16:05 -05:00
parent 9f13cc20a5
commit 9b633672ae

View File

@@ -4,8 +4,6 @@ import { useHttpClient } from '../../hooks/httpClient/UseHttpClient';
import { AxiosInstance, AxiosResponse } from 'axios'; import { AxiosInstance, AxiosResponse } from 'axios';
import { useAccessToken } from '../../hooks/accessToken/UseAcessToken'; import { useAccessToken } from '../../hooks/accessToken/UseAcessToken';
import { useIsAuthenticated } from '@azure/msal-react'; import { useIsAuthenticated } from '@azure/msal-react';
import { Swiper, SwiperSlide } from 'swiper/react';
import { Pagination } from 'swiper/modules';
import { MapContainer, TileLayer } from 'react-leaflet'; import { MapContainer, TileLayer } from 'react-leaflet';
import ReactLeafletKml from 'react-leaflet-kml'; import ReactLeafletKml from 'react-leaflet-kml';
import 'swiper/css'; import 'swiper/css';
@@ -47,33 +45,20 @@ const LogTrackMaps = ({ rowKey, trackUrls }: LogTrackMapsProps) => {
return ( return (
<> <>
<Swiper <MapContainer
spaceBetween={30} center={[45.14489, -93.21019]}
pagination={{ scrollWheelZoom={false}
clickable: true, style={{ height: '500px', width: '100%' }}
}} zoom={8}
modules={[Pagination]}
className="mySwiper"
> >
{tracks.length > 0 && tracks.map((track) => { <TileLayer
return ( attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
<SwiperSlide> url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
<MapContainer />
center={[45.14489, -93.21019]} {tracks.length > 0 && tracks.map((track) => (
scrollWheelZoom={false} <ReactLeafletKml kml={track} />
style={{ height: '500px', width: '100%' }} ))}
zoom={8} </MapContainer>
>
<TileLayer
attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
<ReactLeafletKml kml={track} />
</MapContainer>
</SwiperSlide>
)
})}
</Swiper>
</> </>
); );
} }