parent
1022ad5e97
commit
4315d0301d
@ -1,19 +1,23 @@ |
||||
import { useRef } from 'preact/hooks'; |
||||
import { useMap } from '../hooks/leaflet/useMap'; |
||||
import { type MapViewParameters, useMap } from '../hooks/leaflet/useMap'; |
||||
import { useMapClick } from '../hooks/leaflet/useMapClick'; |
||||
import { useMarkersOnMap } from './hooks/useMarkersOnMap'; |
||||
import type { MapProps } from './types'; |
||||
|
||||
const defaultMapViewParameters = [ |
||||
[47.42111, 10.98528], |
||||
13, |
||||
] satisfies Parameters<typeof useMap>[1]; |
||||
const defaultMapViewParameters: MapViewParameters = [[47.42111, 10.98528], 13]; |
||||
|
||||
const markerLayersStyle = { |
||||
circleStyle: { |
||||
color: 'black', |
||||
radius: 10, |
||||
}, |
||||
}; |
||||
|
||||
export const MapComponent = ({ markers, onMapClick }: MapProps) => { |
||||
const mapContainerRef = useRef<HTMLDivElement>(null); |
||||
const mapRef = useMap(mapContainerRef, defaultMapViewParameters); |
||||
useMapClick(mapRef, onMapClick); |
||||
useMarkersOnMap(mapRef, markers); |
||||
useMarkersOnMap(mapRef, markers, markerLayersStyle); |
||||
|
||||
return <div ref={mapContainerRef} class="map-container" />; |
||||
}; |
||||
|
Loading…
Reference in new issue