Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeoJSON mouse events not triggered with preferCanvas=true #599

Open
digEmAll opened this issue Jul 1, 2020 · 10 comments
Open

GeoJSON mouse events not triggered with preferCanvas=true #599

digEmAll opened this issue Jul 1, 2020 · 10 comments
Labels
bug confirmed Issue is accepted as either a bug or a valid enhancement

Comments

@digEmAll
Copy link

digEmAll commented Jul 1, 2020

Description

The CircleMarker layer seems to block the LGeoJson mouse interactivity when preferCanvas: true.

Live Demo

I prepared the following code-sandbox reproducing the issue:
https://codesandbox.io/s/leaflet-canvas-geojson-click-uy9ez
Usage:
The left map has preferCanvas: true, the right one has preferCanvas: false ;
on the right map you can click on italian regions triggering the event and see the region name in the top-right; on the left map this does not work.

Steps to Reproduce

  • create a map with the option preferCanvas: true
  • add some circles using LCircleMarker
  • add LGeoJson layer and set a mouse event (e.g. click) in the onEachFeature function using layer.on("eventname",fn).

Expected Results

The mouse event calls the callback

Actual Results

The mouse event won't trigger
(but it works fine with map option: preferCanvas: false)

Browsers Affected

Tested on:

  • [x ] Chrome
  • [x ] Firefox
    (but I guess all are affected)

Versions

  • Leaflet: v1.6.0
  • Vue: v2.6.11
  • Vue2Leaflet: v2.5.2

Similar issue (closed) : #358

@DonNicoJs
Copy link
Member

@digEmAll Does this happens for leaflet too? or is a vue2-leaflet specific bug?

@DonNicoJs DonNicoJs added the bug label Jul 16, 2020
@digEmAll
Copy link
Author

digEmAll commented Jul 29, 2020

@DonNicoJs: sorry for the delay, to be honest I'm not sure about the base leaflet library.
If you need it, I can try to build a similar codebox using only leaflet, but at the moment I don't have much time; I'll do it as soon as I can.

Thanks for your quick interest :)

@mikeu
Copy link
Contributor

mikeu commented Aug 28, 2020

I haven't had a chance to look at all into why this might be happening, but it does appear to be a vue2-leaflet issue. Here's a fork of the original repro that uses all the same data with vanilla Leaflet, and which does not exhibit the incorrect behaviour with preferCanvas: true in the map options: https://codesandbox.io/s/leaflet-canvas-geojson-click-forked-ksres?file=/index.js

@mikeu mikeu added the confirmed Issue is accepted as either a bug or a valid enhancement label Sep 11, 2020
@cvakodobro
Copy link

any updates? I have same problem when using circle marker and polygon. If I render only polygons they are clickable, but when I add circle markers, there are no events for polygons.

@mrosminin
Copy link

i have the same bug - after adding layer with LCircleMarkers LGeoJSONLayer looses interactibvity, treated by creation own "LCircleMarker" through extending L.DivIcon.

@demesiooliveira
Copy link

Hi guys, any updates? I have the same problem.

@joingenor
Copy link

Hi guys, any updates? We have the same problem. After adding layer with LCircleMarkers, l-tile-layer looses events

@cupatelj
Copy link

any updates?

@pakal
Copy link

pakal commented Mar 16, 2022

I've investigated a bit, thanks to your sandboxes, I saw the difference was that vuejs circlmarkers added themselves to the markerPane! Without this, all works fine.

It turns out to be this bug actually : Leaflet/Leaflet#6205
Different created by Vue-leaflet, 1 per Pane, hide eachother from mouse events.

So to solve it, I used the NPM plugin provided in the ticket discussion : https://github.com/danwild/leaflet-event-forwarder
I called it from the "ready" event handler of the vue-leaflet map component.

And it worked!!

@jockerfox
Copy link

Hi, I was hoping that with the release of Leaflet 1.8 this bug would be fixed, but it is not.
Does anyone know if this fix is planned?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug confirmed Issue is accepted as either a bug or a valid enhancement
Projects
None yet
Development

No branches or pull requests

10 participants