I have found a solution but not like I think first.
I use a mapbox lib call leaflet-pip
The procedure in detail :
- check click event on all my labels
- do not triger click after map drag (i already had
noclick
on drag start) - get the mouse Lat Lng with
mouseEventToLatLng(e)
- get the polygon with this lat lng
- and finaly trigger click on the result polygon
There is my code to accomplish this :
$(".leaflet-ville-label").off("click").on("click", function(e) {
if ($(this).hasClass("noclick")) {
$(".leaflet-ville-label").removeClass("noclick");
return;
}
for (layer_id in kml_layer._layers) {
var under_layer = leafletPip.pointInLayer(france.mouseEventToLatLng(e), kml_layer._layers[layer_id]);
if (under_layer.length > 0) {
under_layer[0].fire("click");
}
}
});