Leaflet Mouseout called on MouseOver event

后端 未结 3 821
挽巷
挽巷 2021-02-19 05:26

I have a leaflet map where I\'m dynamically adding markers.

I want to call the popup for a marker when I hover over it in addition to when I click the marker.

My

3条回答
  •  说谎
    说谎 (楼主)
    2021-02-19 05:55

    I know it's an old thread but I've just came across this issue and I thought that I can share my solution. Instead of offsetting the popup, I am preventing the popup from stealing the mouse event using CSS by setting:

    .my-popup {pointer-events: none;}
    

    and assigning my-popup className to the popup:

    Marker.on('mouseover', function () {Marker.bindPopup('HI', {className: 'my-popup'}).openPopup();})
    

    I hope this helps someone :)

提交回复
热议问题