GeoJSON mouse events not triggered with preferCanvas=true
See original GitHub issueDescription
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 usinglayer.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) : https://github.com/vue-leaflet/Vue2Leaflet/issues/358
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
D3 geojson map mouse event triggering "poorly"
Map has mouseover and mouseout events tied to counties. Problem: events are triggered only when mouse is slowly and precisely moved on the...
Read more >Click event enabled in OnEachFeature triggering spontaneously
When I load the map, a click event fires for every one of the two thousand features even though I have not clicked...
Read more >Mouse-over events not working when window is in focus
Solved: I have an app that includes a lot of layers, but I am having an issue with some of the point layers...
Read more >GeoJSON — ipyleaflet documentation
import os import json import random import requests from ipyleaflet import Map, GeoJSON if not os.path.exists('europe_110.geo.json'): url ...
Read more >React Leaflet Tutorial using GeoJSON to Create a Map
You will also be introduced on how to add click and mouse events to layers using react leaflet. This will be demonstrated by...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
i have the same bug - after adding layer with LCircleMarkers LGeoJSONLayer looses interactibvity, treated by creation own “LCircleMarker” through extending L.DivIcon.