Skip to content

mapparatus/mapbox-gl-to-blob

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mapbox-gl-to-blob

Render mapbox-gl styles as rasters

stability-unstable Build Status Dependency Status Dev Dependency Status

Install

To install

npm install orangemug/mapbox-gl-to-blob

Usage

Example usage shown below

const mapboxGlToBlob = require("mapbox-gl-to-blob");

const opts = {
  // See <https://www.mapbox.com/mapbox-gl-js/api/#map> for usage
  mapboxGl: {
    // Required arguments
    style: "https://rawgit.com/lukasmartinelli/osm-liberty/gh-pages/style.json",
    // Optional arguments (showing defaults)
    pitch: 0,
    zoom: 0,
    center: [0,0],
    bearing: 0,
  },
  output: {
    dpi: 300,
    dimensions: {
      unit: "mm",
      width: 300,
      height: 300
    }
  }
}

mapboxGlToBlob
  .toBlob(opts)
  .then(function(pngBlob) {
    // ...
  })

Development

Currently the best way to develop this library is via the ./examples

To start the examples just run

npm run examples

..and go to url printed in the terminal.

Browser support

Although at the moment somewhat untested, it should work in all modern browsers. With the exception of IE which will require a polyfill, see

License

MIT