pigeon-maps icon indicating copy to clipboard operation
pigeon-maps copied to clipboard

Custom marker onclick does not work

Open EldinHb opened this issue 1 year ago • 4 comments

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?

EldinHb avatar Dec 08 '23 21:12 EldinHb

Same here

EnriqueRBT avatar Dec 09 '23 09:12 EnriqueRBT

Well, I solved forking and modifing Marker.tsx:

image

EnriqueRBT avatar Dec 09 '23 12:12 EnriqueRBT

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.

santaclawn avatar Jan 03 '24 02:01 santaclawn

any solution ?

shailesh-ss-19-11 avatar Mar 02 '24 17:03 shailesh-ss-19-11