Skip to content

Load vector tiles, re-mixing the layers based on a MapLibre style document

License

Notifications You must be signed in to change notification settings

GlobeletJS/tile-mixer

Repository files navigation

tile-mixer

tests

Re-mix vector tile layers based on a MapLibre style document

Raw vector tile data is organized into a set of layers determined by the tile provider. But for rendering in maps, a new layer definition is specified by the map designer in the MapLibre style document. tile-mixer filters and re-orders the tile data into a new layers object, where the keys are the names of the style layers, and the values are GeoJSON FeatureCollections.

Initialization

A tile-mixer function can be initialized as follows:

import * as tileMixer from 'tile-mixer';

const mixer = tileMixer.init(parameters);

The supplied parameters object has the following properties:

  • layers (REQUIRED): An array containing the layers from the style document that use data from a given source

API

Initialization returns a function with the following signature:

const remixedLayers = mixer(source, zoom);

The arguments are:

  • source: A dictionary of GeoJSON FeatureCollections, with each collection containing the features for each layer of the tile, as returned by tile-retriever
  • zoom: The native zoom level of the tile (usually its z-index)

The return value is a dictionary of FeatureCollections of the remixed tile data. The data structure is comparable to the input source, with the keys of the dictionary replaced by the names of the layers from the style document

About

Load vector tiles, re-mixing the layers based on a MapLibre style document

Resources

License

Stars

Watchers

Forks

Packages

No packages published