2

i'm facing a problem of mouseover event in leaflet the thing is , when i hover ,the weight of the city changes for 2s and it doesn't stay highlighted even though the mouse is over the city here is my code :

function highlightFeature(e) {
    var layer = e.target;
    const { name, CWILAYA } = e.target.feature.properties;
    setSelected({
        name: name,
        CWILAYA: CWILAYA

    });
    layer.setStyle({
        weight: 6,// change the weight  of  a state 
        fillOpacity: 1
    });
    if (!L.Browser.ie && !L.Browser.opera && !L.Browser.edge) {
        layer.bringToFront();
    }
}

function onEachFeature(feature, layer) {
        layer.on({
            mouseover: highlightFeature,// call the function when mouseover  
        });

enter image description here

could you please help me ! thank you

4
  • try strokeWidth style instead of weight Commented Jul 31, 2022 at 7:45
  • the thing is , when i hover ,the weight of the city changes for 2s and it doesn't stay highlighted even though the mouse is over the city Commented Jul 31, 2022 at 8:27
  • did you get the solution ? if yes then please share i am also facing same issue
    – Rana Faraz
    Commented Aug 9, 2022 at 12:32
  • Same here, Did you find a solution? ?
    – Aliénor
    Commented Oct 11, 2022 at 8:08

0

Browse other questions tagged or ask your own question.