pigeon-maps
pigeon-maps copied to clipboard
Custom marker onclick does not work
I cant get onClick to work on a Marker with children.
<Marker
onClick={() => console.log('marker')}
key={route.journeyNumber}
anchor={[Number.parseFloat(route.latLon.latitude), Number.parseFloat(route.latLon.longitude)]}>
<div onClick={() => console.log('marker child')} className='bg-white'>
custom icon
</div>
</Marker>
Neither marker or marker children gets logged. If I remove the children then onClick works on the marker. What am I doing wrong?
Same here
Well, I solved forking and modifing Marker.tsx:
Same issue here. To get around it, I used the Overlay component, instead of the Marker, and setted the onClick function to my custom icon, which is a image, like so:
<Overlay anchor={location}> <img className="image-marker" src={imageMarker} alt="ImageMarker" onClick={() => handleClick(stuff)} /> </Overlay>
I had to offset the image a bit, but when zooming in or out, it had a better behavior then the actual Marker.
any solution ?