mapbox / spritezero

small opinionated sprites
Other
173 stars 62 forks source link

Embed metadata into sprite PNGs #59

Closed kkaefer closed 5 years ago

kkaefer commented 5 years ago

Adds support for embedding sprite JSON metadata as ancillary chunks into the sprite PNG to prevent them from going out of sync.

mourner commented 5 years ago

Yeah you're right, let's go for simplicity here.

lukaswelte commented 5 years ago

@mourner what is needed to push this over the finish line and merge? I would really like to have that feature and would also do changes & commits, but this PR seems to be accepted (by reading the comment), so I wondered, if this can be merged?

kkaefer commented 5 years ago

@lukaswelte we've decided to not pursue this route of embedding the metadata in sprites. While it solves the problem of metadata and image data getting out of sync, it doesn't solve the issue of the style getting out of sync with the sprite. Therefore, we've opted to implement immutable sprite URLs. This solves the problem by always returning the same (historical) data. When a sprite gets updated, we create a new URL for it and write that to the stylesheet so that Mapbox GL loads the new URL rather than trying to refresh the existing resource. This means that historical/cached styles will load the correct sprite that it was authored with.