This is a bit of a hack to remove online dependencies for mapbox to fix #55. This:
Creates marker SVGs for each color listed in config.json including the default color.
Uploads the sprites to the mapbox style to ensure they are in the sprite sheet - rather than dealing with sprite sheet creation, we let mapbox handle this.
Downloads the style and linked glyphs and sprites.
Creates a local version of the style with updated urls for glyphs and sprites
At runtime we need to update the glyphs and sprite urls to point to local assets. mapbox-gl-js would not accept relative URLs, it requires a full URL.
glyphs were tricky: mapbox-gl-js makes multiple requests as you move around the map for specific font stacks and ranges of glyphs. I get around this by parsing the style for all fonts, manually reviewing the network requests for what ranges are requested across the map (fragile!) and downloading all fonts for each range. The url for glyphs must include a {fontstack} tag, which we're ignoring since we've downloaded the entire fontstack and we're serving it as a static asset, so I just append it as a query string so the static server we're using in dev just ignores it.
TODO: The folder structure I'm downloading to doesn't make sense, I think these scripts should probably live in mapfilter-desktop, but then we would need to figure out how to pass the style to mapfilter at runtime.
@gmaclennan this would be cool, although it is old, is this still a valid approach we want to take? IIRC, the observations screen in Md isn't great when offline, it asks you for a map style
This is a bit of a hack to remove online dependencies for mapbox to fix #55. This:
config.json
including the default color.mapbox-gl-js
would not accept relative URLs, it requires a full URL.glyphs were tricky:
mapbox-gl-js
makes multiple requests as you move around the map for specific font stacks and ranges of glyphs. I get around this by parsing the style for all fonts, manually reviewing the network requests for what ranges are requested across the map (fragile!) and downloading all fonts for each range. The url for glyphs must include a {fontstack} tag, which we're ignoring since we've downloaded the entire fontstack and we're serving it as a static asset, so I just append it as a query string so the static server we're using in dev just ignores it.TODO: The folder structure I'm downloading to doesn't make sense, I think these scripts should probably live in mapfilter-desktop, but then we would need to figure out how to pass the style to mapfilter at runtime.