mapbox / mapbox/mapbox-gl-js

Support multi-icon symbols

Open
#4,366 11 comments 20 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cross-platform :tv: feature :green_apple:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Motivation

I want to show a complex set of icons: ~100 basetypes with ~30 modifiers. There is no way to predefine ~3000 icons in the PNG sprite and then just pick the right one. I want to define ~130 and combine them freely. That already works by using two independent layers, but then "basetypes" and "modifiers" are on different z-indices so they interfere with each other.

Design Alternatives

Design 1: make "icon-image" accept an array (has to be implemented on other "icon-" options like "icon-offset" as well)

...
"icon-image": ["{basetype}", "{modifier}"]
...

Design 1a : don´t use an array on every single property but shift it up the to the "paint" and "layout" property.

Design 2: allow the definition of combined icons in the sprite JSON

...
"basetype":{"x":0,"y":0,"width":20,"height":40,"pixelRatio":1},
"modifier":{"x":20,"y":0,"width":20,"height":20,"pixelRatio":1},
"combined":{"icons":["basetype","modifier"], "offset":[[0,0],[0,20]]}
...

Design

Advantages Design 1: dynamic styling
Drawbacks Design 1: complex due to multiplication of icon-properties by number of icons

Advantages Design 2: combined icons would show up like normal icons in the stylesheet
Drawbacks Design 2: need for hard coded combined icons

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

The issue names no source files, tests, or entry points, so there is no direct code starting point. First resolve whether Design 1 or Design 2 is intended and define the behavior of combined icon properties; completion criteria are not specified.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend, web-dev
Issue type
Feature
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.