Map builder

Map builder

Updated 6 years ago by Duncan Clark

This section documents API usage specific to this template, so for an introduction we suggest you refer to the generic API documentation instead.

template: _659

version: _1

Template data

There are three different formats in which you can supply data to this template. The most convenient for you to use likely depends on the source of your data, as described below.

1. Array of arrays, and a bindings object

You can supply arrays of arrays to opts.data, which might look like:

{
    data: {
        choropleth: [
            [ "ChoroplethColumn1Value1", "ChoroplethColumn2Value1",
            [ "ChoroplethColumn1Value2", "ChoroplethColumn2Value2",
            [ "ChoroplethColumn1Value3", "ChoroplethColumn2Value3",
            ...
        ],
        points: [
            [ "PointsColumn1Value1", "PointsColumn2Value1",
            [ "PointsColumn1Value2", "PointsColumn2Value2",
            [ "PointsColumn1Value3", "PointsColumn2Value3",
            ...
        ]
    }
}

where each array of arrays represents the rows in a data sheet.

To tell the API how the values from each column should be associated with the keys that the template is expecting, you must also supply an object attached to opts.bindings. (The meanings of the keys in the bindings object are documented below.) The minimal bindings you can supply for this template are as shown in this example:

{
    template: "_659",
    version: "_1",
    bindings: {
        choropleth: {
            
        },
        points: {
            
        }
    },
    data: {
        choropleth: [
            [ "ChoroplethColumn1Value1", "ChoroplethColumn2Value1",
            [ "ChoroplethColumn1Value2", "ChoroplethColumn2Value2",
            [ "ChoroplethColumn1Value3", "ChoroplethColumn2Value3",
            ...
        ],
        points: [
            [ "PointsColumn1Value1", "PointsColumn2Value1",
            [ "PointsColumn1Value2", "PointsColumn2Value2",
            [ "PointsColumn1Value3", "PointsColumn2Value3",
            ...
        ]
    }
}

All possible bindings that you can supply are shown in this example:

{
    template: "_659",
    version: "_1",
    bindings: {
        choropleth: {
            geometry: 0, // index of a column in your data
            name: 1, // index of a column in your data
            value: 2, // index of a column in your data
        },
        points: {
            lon: 0, // index of a column in your data
            lat: 1, // index of a column in your data
            color: 2, // index of a column in your data
            value: 3, // index of a column in your data
        }
    },
    data: {
        choropleth: [
            [ "ChoroplethColumn1Value1", "ChoroplethColumn2Value1",
            [ "ChoroplethColumn1Value2", "ChoroplethColumn2Value2",
            [ "ChoroplethColumn1Value3", "ChoroplethColumn2Value3",
            ...
        ],
        points: [
            [ "PointsColumn1Value1", "PointsColumn2Value1",
            [ "PointsColumn1Value2", "PointsColumn2Value2",
            [ "PointsColumn1Value3", "PointsColumn2Value3",
            ...
        ]
    }
}

2. Array of objects with arbitrary keys, and a bindings object

This format is most likely useful when you have data from an external source, such as CSV data loaded from d3-dsv. You should supply this attached to the opts.data, which might look like:

{
        choropleth: [
            { "ChoroplethHeader1": ..., "ChoroplethHeader2": ..., ... },
            { "ChoroplethHeader1": ..., "ChoroplethHeader2": ..., ... },
            { "ChoroplethHeader1": ..., "ChoroplethHeader2": ..., ... },
            ...
        ],
        points: [
            { "PointsHeader1": ..., "PointsHeader2": ..., ... },
            { "PointsHeader1": ..., "PointsHeader2": ..., ... },
            { "PointsHeader1": ..., "PointsHeader2": ..., ... },
            ...
        ]
    }

... but with the keys being the column headers from your source data instead. You must also supply an object attached to opts.bindings. The minimal bindings you can supply for this template are as shown in this example:

{
    template: "_659",
    version: "_1",
    bindings: {
        choropleth: {
            
        },
        points: {
            
        }
    },
    data: {
        choropleth: [
            { "ChoroplethHeader1": ..., "ChoroplethHeader2": ..., ... },
            { "ChoroplethHeader1": ..., "ChoroplethHeader2": ..., ... },
            { "ChoroplethHeader1": ..., "ChoroplethHeader2": ..., ... },
            ...
        ],
        points: [
            { "PointsHeader1": ..., "PointsHeader2": ..., ... },
            { "PointsHeader1": ..., "PointsHeader2": ..., ... },
            { "PointsHeader1": ..., "PointsHeader2": ..., ... },
            ...
        ]
    }
}

All possible bindings that you can supply are shown in this example:

{
    template: "_659",
    version: "_1",
    bindings: {
        choropleth: {
            geometry: "ChoroplethHeader1",
            name: "ChoroplethHeader2",
            value: "ChoroplethHeader3",
        },
        points: {
            lon: "PointsHeader1",
            lat: "PointsHeader2",
            color: "PointsHeader3",
            value: "PointsHeader4",
        }
    },
    data: {
        choropleth: [
            { "ChoroplethHeader1": ..., "ChoroplethHeader2": ..., ... },
            { "ChoroplethHeader1": ..., "ChoroplethHeader2": ..., ... },
            { "ChoroplethHeader1": ..., "ChoroplethHeader2": ..., ... },
            ...
        ],
        points: [
            { "PointsHeader1": ..., "PointsHeader2": ..., ... },
            { "PointsHeader1": ..., "PointsHeader2": ..., ... },
            { "PointsHeader1": ..., "PointsHeader2": ..., ... },
            ...
        ]
    }
}

(As before, the keys containing "Header" would be replaced by column names from your data source.)

3. Array of objects with template-defined keys

There is an alternative format you can use, which is likely to be easier to use if your data is not from a spreadsheet source. With this alternative format you supply your data to the template as an array of objects, attached to opts.data, where the keys must be those used by the template, as documented below. In this case there is no need to supply a bindings object, since the key names are already those expected by the template. The required properties in the data object are as follows (scroll down for a description of what each property is):

{
    template: "_659",
    version: "_1",
    data: {},
    ...
}

And the full list of all possible properties is as follows:

{
    template: "_659",
    version: "_1",
    data: {
    choropleth: [
        {
            geometry: ...,
            name: ...,
            value: ...
        },
        ...
    ],
    points: [
        {
            lon: ...,
            lat: ...,
            color: ...,
            value: ...
        },
        ...
    ]
},
    ...
}

Meanings of the template data keys:

  • choropleth.geometry: geometry
  • choropleth.name: name
  • choropleth.value: value
  • points.lon: lon
  • points.lat: lat
  • points.color: color
  • points.value: value

Template settings

Options for opts.state.

Projection

projection string

Projection.

Allowed values:

  • August
  • Azimuthal Equal Area
  • Azimuthal Equidistant
  • Aitoff
  • Baker
  • Boggs
  • Braun's Stereographic
  • Bromley
  • Craster Parabolic
  • Eckert I
  • Eckert II
  • Eckert III
  • Eckert IV
  • Eckert V
  • Eckert VI
  • Eisenlohr
  • Equirectangular
  • Fahey
  • Foucaut
  • Ginzburg IV
  • Ginzburg V
  • Ginzburg VI
  • Ginzburg VIII
  • Ginzburg IX
  • Gnomonic
  • Hammer
  • Kavrayskiy VII
  • McBryde–Thomas Flat-Polar Parabolic
  • McBryde–Thomas Flat-Polar Quartic
  • McBryde–Thomas Flat-Polar Sinusoidal
  • Mercator
  • Mollweide
  • Natural Earth I
  • Natural Earth II
  • Orthographic
  • Peirce Quincuncial
  • Robinson
  • Sinusoidal
  • Stereographic
  • Transverse Mercator
  • Wagner IV
  • Wagner VI
  • Winkel Tripel

fit string

Fit.

Allowed values:

  • map (Quick fit to map bounds)
  • world (Quick fit to show whole world)
  • advanced (Advanced fit)

centering string

Allowed values:

  • rotate (Rotate projection to centre)
  • center (Translate map to centre)

padding number

Padding (%). Percentage of minimum of width and height

Max: 10

min_area number

Minimum area. In km². Polygons representing areas below this size won't be considered when fitting the map. Setting is ignored if no polygons are bigger than the specified minimum area.

longitude number

Long. (°).

latitude number

Lat. (°).

roll number

Rotation (°).

zoom number

Zoom. 1 to show whole world, > 1 to zoom in.

aspect number

Aspect ratio. Width divided by height. If left blank will use aspect ratio of projection for whole world.

precision number

Precision. Lower numbers create smoother lines but may take longer to render

Min: 0.01

Points

point_show boolean

Show points.

point_min_radius number

Minimum radius. Any smaller circles will be scaled up to the specified level. (Ignored if greater than the “Maximum radius” setting.)

point_max_radius number

Maximum radius.

point_default_radius number

Radius.

point_max_value number

Maximum value. Values bigger than this maximum will have a radius equal to the maximum radius. Leave blank to use the maximum in the dataset

point_opacity number

Opacity.

Max: 1

point_fill color

Default fill.

point_color_mode string

Palette type.

Allowed values:

  • specified (Use a specified palette)
  • generated (Use a generated palette)

point_palette colors

Palette.

point_base_color color

Base colour.

point_hue_rotation_angle number

Advanced: hue rotation angle. Angle between one colour and the next (HCL colourspace). The default value, equal to 360/(Golden ratio), ensures adjacent colurs are very different and colours are not repeated.

Max: 360

Map appearance

map_show boolean

Show map.

map_stroke color

Outline colour.

map_stroke_width number

Outline width.

Max: 5

map_stroke_opacity number

Outline opacity.

Max: 1

map_fill color

Fill.

map_fill_opacity number

Fill opacity.

Max: 1

map_shadow boolean

Add shadow.

map_shadow_offset_x number

Horizontal offset.

map_shadow_offset_y number

Vertical offset.

map_shadow_blur number

Blur.

map_shadow_color color

Colour.

map_shadow_opacity number

Opacity.

Max: 1

Graticule

graticule_show boolean

Show graticule.

graticule_color color

Colour.

graticule_width number

Width.

Max: 5

graticule_opacity number

Opacity.

Max: 1

graticule_separation_longitude number

Longitude separation (°).

Min: 1

Max: 180

graticule_separation_latitude number

Latitude separation (°).

Min: 1

Max: 90

Globe

globe_show boolean

Show globe.

globe_color color

Globe colour.

Background

background color

Colour.

Legend

legend_show boolean

Show legend.

legend_interaction boolean

Click legend swatch to hides/show points.

header.title string

Title.

header.subtitle string

Subtitle.

header.color color

Color.

header.align string

Alignment.

Allowed values:

  • left (fa-align-left)
  • center (fa-align-center)
  • right (fa-align-right)

header.margin number

Margin.

header.margin_advanced boolean

Advanced margin settings.

header.margin_top number

Top.

header.margin_right number

Right.

header.margin_bottom number

Bottom.

header.margin_left number

Left.

footer.source_name string

Source name.

footer.source_url string

Source url.

footer.multiple_sources boolean

Multiple sources.

footer.source_name_2 string

Source name.

footer.source_url_2 string

Source url.

footer.source_name_3 string

Source name.

footer.source_url_3 string

Source url.

footer.source_label string

Source label.

footer.note string

Note.

footer.size number

Size.

footer.color color

Color.

footer.align string

Alignment.

Allowed values:

  • left (fa-align-left)
  • center (fa-align-center)
  • right (fa-align-right)

footer.margin number

Overall.

footer.margin_top number

Top.

footer.margin_right number

Right.

footer.margin_bottom number

Bottom.

footer.margin_left number

Left.

footer.margin_advanced boolean

Advanced.