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