Created
December 23, 2021 19:16
-
-
Save jkeefe/775394227513f31e2e9d806e824ffd5c to your computer and use it in GitHub Desktop.
Force raster maps to load as PNGs to preserve transparency
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Force load raster as PNG (Safari will use JPG otherwise) to preserve transparency | |
map.addSource('noaa_map', { | |
type: 'raster', | |
tiles: [ | |
`https://api.mapbox.com/v4/cnndigital.7d5hl52y/{z}/{x}/{y}.png?access_token=${mapboxgl.accessToken}`, | |
], | |
}); | |
map.addLayer({ | |
id: 'raster-layer', | |
type: 'raster', | |
source: 'noaa_map', | |
minzoom: 0, | |
maxzoom: 8, | |
}, 'road-simple'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment