I am using mapbox-gl and downloaded vector tiles from osm2vectortiles.org
I'd like to have the map visible only within an known polygon, and cannot find any way to pull this off.
I can imagine a couple ways to approach the problem, and every path has lead me to no answers. Here are some approaches I've tried to research:
- Some kind of map-masking layer. (Concept doesn't seem to exist)
- Draw the polygon and fill outside it instead of inside it. (Seems you can only fill inside polygons)
- Draw a filled box around the outer bounds of the map, and cutout the polygon. (MultiPolygon Features seem to stack instead of cutout)
- Modify the mbtiles to pretend everything outside the polygon is water. (https://github.com/mapbox/mbtiles-cutout seemed promising, but I can't seem to get it to work)
What's the right way to approach this problem?
turf.difference()
to invert the selected space. I really appreciate the completeness of your answer. You Rock! – Wendalyn