Only mouse over one feature at a time
This commit is contained in:
parent
6345a10561
commit
320c46c6d5
@ -200,37 +200,35 @@ L.Canvas = L.Renderer.extend({
|
|||||||
if (!this._map || this._map._animatingZoom) { return; }
|
if (!this._map || this._map._animatingZoom) { return; }
|
||||||
|
|
||||||
var point = this._map.mouseEventToLayerPoint(e);
|
var point = this._map.mouseEventToLayerPoint(e);
|
||||||
var id;
|
this._handleMouseOut(e, point);
|
||||||
|
this._handleMouseHover(e, point);
|
||||||
// TODO don't do on each move event, throttle since it's expensive
|
|
||||||
for (id in this._layers) {
|
|
||||||
this._handleMouseOut(this._layers[id], e, point);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (id in this._layers) {
|
|
||||||
this._handleMouseHover(this._layers[id], e, point);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleMouseOut: function (layer, e, point) {
|
_handleMouseOut: function (e, point) {
|
||||||
if (layer.options.interactive && layer._mouseInside && !layer._containsPoint(point)) {
|
var layer = this._hoveredLayer;
|
||||||
|
if (layer && !layer._containsPoint(point)) {
|
||||||
// if we're leaving the layer, fire mouseout
|
// if we're leaving the layer, fire mouseout
|
||||||
L.DomUtil.removeClass(this._container, 'leaflet-interactive');
|
L.DomUtil.removeClass(this._container, 'leaflet-interactive');
|
||||||
this._fireEvent(layer, e, 'mouseout');
|
this._fireEvent(layer, e, 'mouseout');
|
||||||
layer._mouseInside = false;
|
this._hoveredLayer = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleMouseHover: function (layer, e, point) {
|
_handleMouseHover: function (e, point) {
|
||||||
|
var id, layer;
|
||||||
|
if (!this._hoveredLayer) {
|
||||||
|
for (id in this._layers) {
|
||||||
|
layer = this._layers[id];
|
||||||
if (layer.options.interactive && layer._containsPoint(point)) {
|
if (layer.options.interactive && layer._containsPoint(point)) {
|
||||||
// if we just got inside the layer, fire mouseover
|
|
||||||
if (!layer._mouseInside) {
|
|
||||||
L.DomUtil.addClass(this._container, 'leaflet-interactive'); // change cursor
|
L.DomUtil.addClass(this._container, 'leaflet-interactive'); // change cursor
|
||||||
this._fireEvent(layer, e, 'mouseover');
|
this._fireEvent(layer, e, 'mouseover');
|
||||||
layer._mouseInside = true;
|
this._hoveredLayer = layer;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
// fire mousemove
|
}
|
||||||
this._fireEvent(layer, e);
|
}
|
||||||
|
if (this._hoveredLayer) {
|
||||||
|
this._fireEvent(this._hoveredLayer, e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user