layer on click event not always fired when a popup is used

16 views
Skip to first unread message

Evgeny Kleiman

unread,
Feb 17, 2017, 5:13:50 AM2/17/17
to Leaflet
I have the a layer with on click handler:
countriesLayer = L.geoJson(ct,
   {
       style: myStyle,
       onEachFeature: onEachFeature
   }
   )

 function onEachFeature(feature, layer) {

    var center = setLabelCenter(layer);
    feature.center = [center.lng, center.lat];
    layer.on({
            click: onFeatureClick,
             mouseover: showMapTip,
    });

Also I have a popup for mouse over:

 function showMapTip(e) {
        var layer = e.target;      
        var content = getInfoContent(layer.feature.properties);        
        layerPopup = L.popup( {
                      autoPan : false
            })
        .setLatLng(e.latlng)
           .setContent(content)
           .openOn(mymap)
    }
The problem is that onClick event is not always fired. More exactly, it is fired in about 10% cases. If I cancel popup the it works.
Is it possible to solve the problem?


Reply all
Reply to author
Forward
0 new messages