@beyondtracks/mapbox-gl-raster-tile-splitter

0.2.1 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i @beyondtracks/mapbox-gl-raster-tile-splitter

Weekly Downloads

0

Version

0.2.1

License

BSD-2

Unpacked Size

9.82 kB

Total Files

7

Last publish

Collaborators

  • andrewharvey