Reputation: 3809
I would like to handle touchstart
and touchend
events on the react-leaflet map component but seem to be unable to do so - what am I missing?
Here's what I tried - general setup:
<MapContainer>
<MapInitializer />
...
</MapContainer>
function MapInitializer() {
const map = useMap();
const handleTouchStart = (event) => {
alert('DEBUG touchstart 1');
}
map.on('touchstart', handleTouchStart);
}
useMapEvent
as per the docsfunction MapInitializer() {
const map2 = useMapEvent('touchstart', () => {
alert('DEBUG touchstart 2');
});
}
<MapContainer touchStart='handleTouchStart'>
...
</MapContainer>
Upvotes: 0
Views: 37