Leaflet / Leaflet/Leaflet.VectorGrid

The "click" event cannot be generated on layers with point geometry.

Open
#294 3 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
676
Forks
202
PR merge metrics
No merged PRs in 30d

Description

Hi everyone. I'm trying to capture the "click" event of an L.VectorGrid.Protobuf instance as follows:

layer.on("click", handler);

The event works for layers with "Polygon" and "LineString" geometry; however, for "Point" geometry layers, the following error appears in the console:

Uncaught TypeError: Cannot read properties of undefined (reading 'lat')
    at Object.project (leaflet.js?v=49550133:1117:95)
    at Object.latLngToPoint (leaflet.js?v=49550133:1019:48)
    at NewClass.project (leaflet.js?v=49550133:2646:35)
    at NewClass.latLngToLayerPoint (leaflet.js?v=49550133:2665:37)
    at NewClass.latLngToContainerPoint (leaflet.js?v=49550133:2715:55)
    at NewClass._fireDOMEvent (leaflet.js?v=49550133:2954:51)
    at NewClass._handleDOMEvent (leaflet.js?v=49550133:2923:16)
    at HTMLDivElement.handler (leaflet.js?v=49550133:1733:21)

My map's initialization has no parameters other than zoom and center. The layer has the interactive parameter set to true.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the L.VectorGrid.Protobuf entry point and its layer.on("click", handler) event path, then reproduce the failure using a point-geometry layer with interactive enabled. Trace how the Leaflet DOM event handler obtains the event location; done means point clicks fire without the undefined lat error. No repository file or test is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.