Leaflet / Leaflet/Leaflet.VectorGrid

protobuf vectorTileLayerStyles: filter out some elements

Open
#192 2 comments 0 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

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?

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 at the vectorGrid.protobuf entry point and inspect how vectorTileLayerStyles are applied to protobuf features. Determine where nonmatching cities could be excluded before rendering, and verify that matching cities remain styled while excluded points no longer contribute to map rendering or scrolling performance.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 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.