digidem / react-mapfilter

Visualizing, exploring, filtering and printing geographic data and geotagged photos and video
https://lab.digital-democracy.org/mapfilter
29 stars 11 forks source link

Allow any vector tile style #51

Open gmaclennan opened 8 years ago

gmaclennan commented 8 years ago

Right now the marker sprites need to be added to any vector tile style that is used. mapbox-gl-js currently only allows one sprite sheet per style, so you need to use [Mapbox Studio]() to add the marker sprites to the style online. Ideally we want to enable any custom style to be used as a background in MapFilter, without modifying the sprites.

My current strategy for solving this is to concatenate the remote sprite file from the map style with the sprite for the marker sprites, using concat-sprites. This can be done dynamically in the browser, but getting the new merged sprite into mapbox-gl-js is a challenge. We could serve the sprite over an objectURL but mapbox-gl-js currently expects both the json and png to share the same url root. We could serve both using Service Workers, but with limited browser support, or create a fork of mapbox-gl-js and write a custom image_sprite.js. I'm thinking the latter might be the easier (hacky) solution for now. Hopefully Mapbox will support dynamic sprites in the near future.