@beyondtracks/mapbox-gl-raster-tile-splitter
v0.2.1
Published
A Mapbox GL JS transformRequest function to split a single raster source request to a range of raster tile endpoints.
Downloads
4
Readme
mapbox-gl-raster-tile-splitter
A Mapbox GL JS transformRequest function to split a single raster source request to a range of raster tile endpoints.
Usage
Add via npm with
yarn add @beyondtracks/mapbox-gl-raster-tile-splitter
import rasterTileSplitter from '@beyondtracks/mapbox-gl-raster-tile-splitter'
Add via script with
<script src='dist/rasterTileSplitter.js'></script>
Example
var rasterSources = {
type: 'Feature',
properties: {
url: 'https://example.com/secondarySource/{z}/{x}/{y}'
},
geometry: {
type: 'Polygon',
coordinates: ...
}
};
new mapboxgl.Map({
style: {
version: 8,
sources: {
raster: {
type: 'raster',
tiles: ['https://example.com/primarySource/{z}/{x}/{y}'],
tileSize: 256
}
},
layers: ...
},
transformRequest: rasterTileSplitter(sources, 'https://example.com/primarySource')
});
This will result in the raster source using the primarySource, exect for tiles that fall within the bounds of the polygon used for the secondarySource.