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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protobuf vectorTileLayerStyles: filter out some elements #192

Open
bagage opened this issue Jan 27, 2019 · 2 comments
Open

protobuf vectorTileLayerStyles: filter out some elements #192

bagage opened this issue Jan 27, 2019 · 2 comments

Comments

@bagage
Copy link

bagage commented Jan 27, 2019

I am using a protobuf tile server which returns me cities, and I'd like to draw only some of them, for instance the one starting with letter A (could be anything else actually).

Yet I am using:

L.vectorGrid.protobuf(
  tilesServerUrl,
  vectorTileLayerStyles: {
    "cities": (properties, zoom) => {
      if (properties.name.indexOf('a') !== 0) {
        return {
          fillOpacity: 0,
          stroke: false,
          fill: false,
          opacity: 0,
          weight: 0,
        };
      } else {
        return {
          weight: 2,
          color: 'red',
          fill: true,
          fillOpacity: 0.8
        };
      }
    }
  }
);

~~My issue is, I believe, that all my cities are still drawn and that makes the map scroll very laggy because there are too much points on the map. ~~ Actually vectorGrid by itself is fine, it is combined with angular that the issue rises really. But filtering out points would solve the issue so still keeping this issue open for my part.

Thus I'd like to totally filter out the cities not matching given criteria. Is that possible?

@bagage bagage changed the title protobuf vectorTileLayerStyles: do not draw some elements protobuf vectorTileLayerStyles: filter out some elements Jan 27, 2019
@jamesurobertson
Copy link

For anyone else finding this page you should be able to return an empty array [] and it wont draw anything on the map.

@Matteomt
Copy link

Matteomt commented Nov 29, 2024

For anyone else finding this page you should be able to return an empty array [] and it wont draw anything on the map.

Could you please clarify which function should return the empty array?

I tried the functions mapped under vectorTileLayerStyles, but it does not work. Also, the function typing does not seem to allow returning an array.

I also tried the filter option that I can find in the type, but that doesn't work either: the function doesn't even get called to evaluate the filter condition (see issue: #285 ).

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

3 participants