question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GeoJSON mouse events not triggered with preferCanvas=true

See original GitHub issue

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) : https://github.com/vue-leaflet/Vue2Leaflet/issues/358

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
cvakodobrocommented, Dec 7, 2020

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.

1reaction
mrosminincommented, Sep 9, 2021

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found