mapbox / mapbox/mapbox-gl-js

Style spec: allow metadata in sources

Open
#5,471 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

The tiles source type can be extended to add metadata (https://github.com/mapbox/mapbox-gl-js/blob/master/src/style-spec/reference/v8.json#L161), but others like GeoJSON error on validation. Since it is possible to put metadata in layers, and in the root of the style, why not in sources too? :)

I guess there is a decision here between using a single "metadata" object or a TileJSON compatible spec for sources?

It would also work to write my own custom validation (https://github.com/mapbox/mapbox-gl-js/issues/3003) but that would probably be overkill just to allow some metadata fields.

I am using this to store metadata that applies to the data itself, like human readable labels and and attribution for the data properties, that would be best stored with the source instead of duplicated in multiple layers. My app assembles and saves maps dynamically so it is easier to save everything in the style object. My hack for the moment is to move the metadata down into the GeoJSON object, but that makes it inconsistent with sources I load from TileJSON. In my case I'm particular interested in documenting the fields, there is some discussion on that in TileJSON here https://github.com/mapbox/tilejson-spec/issues/14

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 with src/style-spec/reference/v8.json at the source definitions and trace the validation path that rejects metadata for GeoJSON sources. Resolve whether source metadata should use one object or TileJSON-compatible fields, then verify the chosen design works consistently across source types without validation errors.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.