Leaflet / Leaflet/Leaflet.VectorGrid

Refactor vectorTileLayerStyles into Symbolizers

Open
#76 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

When I first made this, I really gave a lot of thought to the vectorTileLayerStyles option. It was just the fastest idea at that time.

With some of the more complex vector tile sources, the styling can get out of hand.

And not to speak of the confusion between data layers and leaflet layers.

So I'm thinking of changing the paradigms (or at least, the names), by adopting the good old "Symbolizer" nomenclature from Mapnik.

So instead of stuff like...

var vectorGrid = L.vectorGrid.protobuf(url, {
   vectorTileLayerStyles: {
      water: {[
         fill: 'blue'
      ]},
      roads: function(props, zoom) { if (zoom > 10) return {color: 'black'}; else return null; }
   }
}).addTo(map);

I'd have something like...

var vectorGrid = L.vectorGrid.protobuf(url);
vectorGrid.addSymbolizer('water', 'fill', {fill: 'blue'});
vectorGrid.addSymbolizer('roads', 'line', function(props, zoom) {...} );
vectorGrid.addTo(map)

The problem with the current approach is that the vectorTileLayerStyles easily gets 3 or 4 nested levels of brackets and braces, and then you have to put that in an options object.

It should be easy to keep a symbolizers option, and vectorTileLayerStyles as a legacy alias for it; let users use addSymbolizer only for the more complex styles.

@perliedman @jkuebart Opinions?

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 reviewing the current vectorTileLayerStyles option and the proposed symbolizers option and addSymbolizer entry points described in the issue. Compare the existing nested style forms with the proposed Symbolizer naming, then clarify the compatibility and API decisions before implementation; done means the new approach and legacy alias have an agreed, testable scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.