open-index/open-npm huggingface dataset:
npm package: @sodra/ak-draw-canvas
Description: Draw map on canvas. Fetches vector tiles from specified url.
Latest version: 1.2.2

# ak-draw-canvas

Draw map on canvas. Fetches vector tiles from specified url. 

To be used both in the browser and on the server (requires [node-canvas](https://github.com/Automattic/node-canvas)).

## Install

```sh
$ npm install @sodra/ak-draw-canvas
```
 
## Usage

```sh
let Canvas = require('canvas'),
    styles = require('@sodra/ak-styles')

let drawCanvas = require('@sodra/ak-draw-canvas')({
  url: '<vtiles-url>',
  createCanvas: function (width, height) {
    return new Canvas(width, height)
  }
})

let params = {
  lat: 63.82621,
  lng: 20.261364,
  zoom: 19,
  width: 1000,
  height: 1400
}

let style = styles['pop-teal-marsala']

drawCanvas(params, style, function (err, canvas) {
  // use canvas
})
 
```

In the browser "new Canvas()" is not available:

```sh
let drawCanvas = require('@sodra/ak-draw-canvas')({
  url: '<vtiles-url>',
  createCanvas: function (width, height) {
    let canvas = document.createElement('canvas')
    canvas.width = width
    canvas.height = height
    return canvas
  }
})
```