how to catch the click event on a leaflet popup

后端 未结 1 2083
傲寒
傲寒 2021-01-22 15:19

I\'m having multiple popups on a leaflet map open at the same time, and they can overlap. I want to bring a popup to front if clicked on. While I have no trouble getting the cli

相关标签:
1条回答
  • 2021-01-22 15:41

    The setContent method of L.Popup accepts HTML elements so you could do something like this:

    var content = L.DomUtil.create('div', 'content'),
        popup = L.popup().setContent(content);
    
    L.DomEvent.addListener(content, 'click', function(event){
        // do stuff
    }, context);
    

    Reference:

    https://leafletjs.com/reference.html#domutil

    https://leafletjs.com/reference.html#event

    0 讨论(0)
提交回复
热议问题