File tree Expand file tree Collapse file tree
src/components/Projekte/Karte Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { useSetAtom , useAtomValue } from 'jotai'
22import * as ReactDOMServer from 'react-dom/server'
3- import { useMapEvent } from 'react-leaflet/hooks'
3+ import { useMapEvent , useMap } from 'react-leaflet/hooks'
44import { gql } from '@apollo/client'
55import { useApolloClient } from '@apollo/client/react'
66import L from 'leaflet'
@@ -24,9 +24,12 @@ export const ClickListener = () => {
2424
2525 const apolloClient = useApolloClient ( )
2626
27- const map = useMapEvent ( 'click' , async ( event ) => {
27+ const map = useMap ( )
28+
29+ const onClick = async ( event ) => {
2830 const { lat, lng } = event . latlng
2931 const zoom = map . getZoom ( )
32+ console . log ( 'map clicked' , { lat, lng, zoom } )
3033 // idea 1:
3134 // get all layers
3235 // run onEachFeature on all layers
@@ -478,7 +481,9 @@ export const ClickListener = () => {
478481 /> ,
479482 )
480483 L . popup ( ) . setLatLng ( event . latlng ) . setContent ( popupContent ) . openOn ( map )
481- } )
484+ }
485+
486+ useMapEvent ( 'click' , onClick )
482487
483488 return null
484489}
You can’t perform that action at this time.
0 commit comments