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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter not working with L.VectorGrid.Protobuf 馃敶 #285

Open
geekypradip opened this issue Apr 17, 2024 · 2 comments
Open

Filter not working with L.VectorGrid.Protobuf 馃敶 #285

geekypradip opened this issue Apr 17, 2024 · 2 comments

Comments

@geekypradip
Copy link

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.

@IvanSanchez
Copy link
Member

@geekypradip My question to you is: Why did you think there's a filter option implemented in VectorGrid?

@geekypradip
Copy link
Author

geekypradip commented Apr 17, 2024

@geekypradip My question to you is: Why did you think there's a filter option implemented in VectorGrid?

Thank you for your prompt response. I assumed the filter option was available because it's mentioned in the TypeScript definitions for leaflet.vectorgrid on npm. Here's the link for reference: DefinitelyTyped vector grid

Upon further investigation, I noticed a discrepancy between the npm package version and the master branch of the repository. The npm package is at version 1.3.0, where the filter option is not available. However, the TypeScript definitions seem to be based on the master branch, where the filter option is indeed present in the VectorGrid options.

This mismatch between the released version and the TypeScript definitions could be causing some confusion. I would appreciate any guidance on how to proceed with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants