Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

mapbox-gl-function

Package Overview
Dependencies
Maintainers
41
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mapbox-gl-function

Evaluate a Mapbox GL style function


Version published
Weekly downloads
295
decreased by-13.99%
Maintainers
41
Weekly downloads
 
Created
Source

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.

Note that other Mapbox tools currently use v1, not v2.

Usage

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

var exponential = glfun({type: 'exponential', domain: [1, 5], range: [1, 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', domain: [1, 3, 4], range: ['a', 'b', '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', domain: ['A', 'B', 'C'], range: ['a', 'b', 'c']});
categorical({ $zoom: 'A' }); // => 'a'
categorical({ $zoom: 'B' }); // => 'b'
categorical({ $zoom: 'C' }); // => 'c'

FAQs

Package last updated on 06 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc