Leaflet Maps: Why only click ( and not mouseover) events caught for L.Rectangle (jsbin example)?

StackOverflow https://stackoverflow.com/questions/13519791

  •  01-12-2021
  •  | 
  •  

Question

enter image description here

I am using Leaflet 0.4.5 http://leafletjs.com/reference.html#rectangle , and I place a bunch of L.Rectangles on a map, and attach both a mouse click and mouseover event handler (one handler for both events) As you can see from this demo: http://jsbin.com/ojupus/4/edit If you mouse over a rectangle with the [d]/[delete] or [s] key pressed nothing happens. You have to actually click the rectangle. Why? (use the D: key to delete a box, S: key to change the color of a box).

Another apparent glitch is that if your use the layer control to turn off the drawings overlay, and then mouse-click (with [d] or with [s]) you can delete or change the style of an L.Rectangle that is not visible on the screen. Is this an expected result in using FeatureGroups? I would think if it is not visible, it should not get the events (and by the way, it is very hard to find the containing FeatureGroup) for these boxes, so I have no idea if the FeatureGroup is visible or not).

Anyway feel free to clone the JSBIN and tell me if you see anything I am missing.

Was it helpful?

Solution

I am now using Leaflet v 0.6 and it works fine for mouse over.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top