mapbox-gl-function

Evaluate a Mapbox GL style function

This package has been merged with the 'mapbox-gl-style-spec' package
Last updated 9 years ago by lucaswoj .
ISC · Repository · Bugs · Original npm
$ cnpm install mapbox-gl-function 
SYNC missed versions from official npm registry.

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 exponential = glfun({type: 'exponential', stops: [[1, 1], [5, 10]]});
exponential({ $zoom: 0 });  // => 1
exponential({ $zoom: 1 });  // => 1
exponential({ $zoom: 3 });  // => 5.5
exponential({ $zoom: 5 });  // => 10
exponential({ $zoom: 11 }); // => 10

var interval = glfun({type: 'interval', stops: [[1, 'a'], [3, 'b'], [4, 'c']]});
interval({ $zoom: 0 }); // => 'a'
interval({ $zoom: 1 }); // => 'a'
interval({ $zoom: 2 }); // => 'a'
interval({ $zoom: 3 }); // => 'b'
interval({ $zoom: 4 }); // => 'c'

var categorical = glfun({type: 'categorical', stops: [['A', 'a'], ['B', 'b'], ['C', 'c']]});
categorical({ $zoom: 'A' }); // => 'a'
categorical({ $zoom: 'B' }); // => 'b'
categorical({ $zoom: 'C' }); // => 'c'

Current Tags

  • 1.3.0                                ...           latest (9 years ago)

1 Versions

  • 1.3.0 [deprecated]           ...           9 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (2)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org