@sodra/ak-draw-canvas
v1.2.2
Published
Draw map on canvas. Fetches vector tiles from specified url.
Downloads
3
Keywords
Readme
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 @sodra/ak-draw-canvas
Usage
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:
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
}
})