JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1265
  • Score
    100M100P100Q19004F
  • License ISC

Evaluate a Mapbox GL style function

Package Exports

  • mapbox-gl-function

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mapbox-gl-function) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Mapbox GL style functions are used to specify a property value that varies according to zoom level. This library implements the semantics of interpolated and piecewise-constant functions as specified by the Mapbox GL Style Specification.

Usage

var glfun = require('mapbox-gl-function');

var interpolated = glfun['interpolated']({stops: [[1, 1], [5, 10]]});
interpolated(0);  // => 1
interpolated(1);  // => 1
interpolated(3);  // => 5.5
interpolated(5);  // => 10
interpolated(11); // => 10

var piecewiseConstant = glfun['piecewise-constant']({stops: [[1, "a"], [3, "b"], [4, "c"]]});
piecewiseConstant(0); // => "a"
piecewiseConstant(1); // => "a"
piecewiseConstant(2); // => "a"
piecewiseConstant(3); // => "b"
piecewiseConstant(4); // => "c"