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

Static assets #60

Open
wants to merge 2 commits into
base: rewrite
Choose a base branch
from
Open

Static assets #60

wants to merge 2 commits into from

Conversation

gmaclennan
Copy link
Member

This is a bit of a hack to remove online dependencies for mapbox to fix #55. This:

  1. Creates marker SVGs for each color listed in config.json including the default color.
  2. 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.
  3. Downloads the style and linked glyphs and sprites.
  4. Creates a local version of the style with updated urls for glyphs and sprites
  5. 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.

@okdistribute
Copy link
Contributor

@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

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

Successfully merging this pull request may close these issues.

2 participants