I am drawing a multiple circle using Leaflet API. I need to apply hover effect so that I can hover on circle it will rise up or bring to front. I am using the following codes

for (var i = 0; i < count; i++) {
var circleLayer = L.circle([latitude[i], longitude[i]], bufferDistance[i], {
    color: 'white',
    weight: 1,
    fillColor: getColor(data),
    fillOpacity: 0.8,
    riseOnHover: true
circleLayer.on('mouseover', function(circleLayer) {

All the circles are drawing accordingly but there is no mouseover or hover action is taking place. What I am doing wrong?


Your mistake is in the mouseover event function. The parameter given to an event function is the event itself. To get the object inside the event function you have access to the "target" property of the event.

circleLayer.on('mouseover', function(e) {

This fiddle shows how to make it work.

Little extra detail : "riseOnHover" option is useless for circle.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.