Small preact-based (like React.js) project https://inga-lovinde.github.io/static/komoot-demo/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

20 lines
680 B

import { useRef } from 'preact/hooks';
import { MapProps } from './types';
import { useMap } from './hooks/useMap';
import { useMapClick } from './hooks/useMapClick';
import { useMarkersOnMap } from './hooks/useMarkersOnMap';
const defaultMapViewParameters = [
[47.42111, 10.98528],
13,
] satisfies Parameters<typeof useMap>[1];
export const MapComponent = ({ markers, onMapClick }: MapProps) => {
const mapContainerRef = useRef<HTMLDivElement>(null);
const mapRef = useMap(mapContainerRef, defaultMapViewParameters);
useMapClick(mapRef, onMapClick);
useMarkersOnMap(mapRef, markers);
return <div ref={mapContainerRef} class="map-container" />;
};