block by martgnz 867c95c3b13ac538ad2a64945bc5cf80

Using Spam with Browserify

Full Screen

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.

index.html

main.js