mapbox / mapbox/mapbox-gl-js

Support of paints array

Open
#9,752 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature :green_apple: needs discussion :speech_balloon:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Motivation

Its a common requirement to add multiple layers to provide a stack of paints like a circle with a circle underneath (maybe a blurred circle to create a shadow effect.)

export const unclusteredPointLayerShadow = {
  id: "unclustered-point-shadow",
  type: "circle",
  filter: unclusteredPointFilter,
  paint: {
    "circle-radius": ["+", 10, ["to-number", ["get", "size"]]],
    "circle-color": "#000000",
    "circle-blur": 0.5,
  },
}

export const unclusteredPointLayer = {
  id: "unclustered-point",
  type: "circle",
  filter: unclusteredPointFilter,
  paint: {
    "circle-radius": { type: "identity", property: "size" },
    "circle-color": { type: "identity", property: "color" },
    "circle-stroke-width": { type: "identity", property: "strokeSize" },
    "circle-stroke-color": { type: "identity", property: "scolor" },
  },
}

Design Alternatives

For those paints where the filter conditions are the same, it makes sense to define them in an array instead of two different layers.

...
paints: [{
    "circle-radius": { type: "identity", property: "size" },
    "circle-color": { type: "identity", property: "color" },
    "circle-stroke-width": { type: "identity", property: "strokeSize" },
    "circle-stroke-color": { type: "identity", property: "scolor" },
  }, {
    "circle-radius": ["+", 10, ["to-number", ["get", "size"]]],
    "circle-color": "#000000",
    "circle-blur": 0.5,
}]

Its just an idea from my humble developer point of view, but maybe it could also be a performance improvement for the described cases.

Contributor guide

Open the contributing guide

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 how mapbox-gl-js currently defines and processes a layer's paint property, then compare that with the proposed paints array examples in this issue. Determine the required style representation, rendering behavior, validation, and compatibility expectations before implementation; done means multiple paint layers work with the same filter and preserve existing single-paint behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.