0.2.1 • Published 4 years ago

@beyondtracks/mapbox-gl-raster-tile-splitter v0.2.1

Weekly downloads
1
License
BSD-2
Repository
gitlab
Last release
4 years ago

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.

0.2.1

4 years ago

0.2.0

4 years ago