Install Spam with npm (npm install spamjs
), and require the deps in your main JavaScript file:
var d3 = require('d3')
var topojson = require('topojson')
var spam = require('spamjs')
Now you can create a map with spam.StaticCanvasMap()
or spam.ZoomableCanvasMap()
:
var map = new spam.StaticCanvasMap({
element: "body",
width: width,
height: height,
projection: d3.geo.orthographic()
.clipAngle(90)
.precision(0.1)
.scale(250),
data: [...]
Tip: I find watchify useful for updating the bundle automatically.