@davvo/ak-draw-canvas

1.1.0 • Public • Published

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).

Install

$ npm install @davvo/ak-draw-canvas

Usage

let Canvas = require('canvas'),
    styles = require('@davvo/ak-styles')

let drawCanvas = require('@davvo/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:

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

Readme

Keywords

none

Package Sidebar

Install

npm i @davvo/ak-draw-canvas

Weekly Downloads

1

Version

1.1.0

License

none

Last publish

Collaborators

  • davvo