Leaflet / Leaflet/Leaflet.VectorGrid

Filter not working with L.VectorGrid.Protobuf 🔴

Open
#285 3 comments 1 reaction 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

I'm currently working with Leaflet's VectorGrid and I'm encountering an issue with the filter option. Here's a snippet of my code:

const vectorGrid = L.vectorGrid.protobuf(url, {
      vectorTileLayerStyles: vectorTileLayerStyles as Record<
        string,
        PathOptions
      >,
      rendererFactory: L.svg.tile,
      maxNativeZoom: 28,
      maxZoom: 28,
      interactive: true,
      fetchOptions: {headers: {Authorization: `Bearer ${token}`}},
      bounds: bounds,
      zIndex: 1000,
      filter: (properties, zoom) => {
        console.log(properties, zoom);
        return false;
      },
    });

In the above code, I've provided a filter function that should prevent any feature from being rendered on the map, as I'm returning false. However, it seems like the filter function is not being called at all. I've tried to debug this using Chrome's devtools and added a console.log statement inside the filter function, but it's not printing anything.

The strange thing is, whether I pass the filter option or not, the result is the same. It's as if the filter function is being completely ignored.

Any help or guidance on this issue would be greatly appreciated.

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 by reproducing the issue with L.vectorGrid.protobuf and the provided filter callback, then trace how the filter option is handled for protobuf vector tiles. Confirm that the callback is invoked and that returning false prevents features from being rendered, using the console output and map result as the completion criteria.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.