cartodb-leaflet
cartodb-leaflet copied to clipboard
Mouseover on multiple layers
The mouseOut event is fired immediately after the mouseOver event for layers that are underneath other layers; therefore, only the top layer has accurate mouseOver / mouseOut events.
Here's our moderately painful solution:
var me = this;
this.detectMouseOutSet = {};
this.featureMouseOver = function( ... ) {
me.detectMouseOutSet[ this.table_name ] = false;
// do stuff
document.body.style.cursor = 'pointer';
}
this.featureMouseOut = function( ... ) {
me.detectMouseOutSet[ this.table_name ] = true;
for ( var p in me.detectMouseOutSet ) {
if ( !me.detectMouseOutSet[ p ] ) return;
}
// do stuff
document.body.style.cursor = 'default';
}