Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style spec: allow metadata in sources #5471

Open
kriscarle opened this issue Oct 16, 2017 · 1 comment
Open

Style spec: allow metadata in sources #5471

kriscarle opened this issue Oct 16, 2017 · 1 comment

Comments

@kriscarle
Copy link

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 (#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 mapbox/tilejson-spec#14

@redbmk
Copy link

redbmk commented Dec 15, 2017

It seems like we should also be able to add metadata to TileJSON sources and access that from e.g. map.getSource(id).metadata. Unless I'm understanding it wrong, the latest TileJSON spec mentions that if you add keys that aren't part of the TileJSON spec, you should be able to access those. However, mapbox-gl-js strips out all but a few keys.

Implementations MUST treat unknown keys as if they weren't present. However, implementations MUST expose unknown key/values in their API so that API users can optionally handle these keys. Implementations MUST treat invalid values for keys as if they weren't present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants