Icon map

“Marker” or “locator” map with emoji, icons or images for places and an inset map for context

Updated 6 months ago by Template retirement home

How to use this template

What's it for?

Use this template to display a collection of icons on a map. These can be icons you specify yourself, emoji, or Font Awesome icons.

How to get started

  1. You'll need two CSV or Excel files. One will contain the locations of the points shown on your map. The other is a list of categories to assign to your points.
  2. The data file will need (at a minimum) columns for the icon categories, latitudes and longitudes. Here's an example:
    category latitude longitude
    Tube Station -6.081689835 145.3919983
    Tube Station -5.207079887 145.7890015
    Comment -5.826789856 144.2960052
  1. The categories file will need (at a minimum) columns for the category name and its icon. Here's an example:
    Category Name Icon
    Tube Station 🚇
    Comment fa-comment

Not sure how to upload your data to Flourish? See our handy guide

FAQ

How do I reset the initial zoom and centre of the map? For the moment, you need to do this: (1) Create a story from your visualisation (2) Zoom and pan the slide to adjust the zoom and centre of the map (3) In the left-hand menu, under "Navigation", choose "None" (4) Publish the story.

How do I change the colour of the icons? By changing the values in the colour column in the "Categories" table, you can set the icon colour for a whole category. There is also a colour column in the "Locations" table, which can be used to specify the colour of individual icons.

Note that only Font Awesome icons can be given custom colours. You can find a full list of available icons here.

How can I highlight different points on the map? Create a story from your visualisation, then add multiple slides to highlight different views of the data. See the example story below.

Examples

Credits

Created by the Flourish team, using Mapbox GL JS. Want to see additional features? Let us know at support@flourish.studio.

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

template: _784

version: _4

Template data

There are two different formats in which you can supply data to this template. Which one will be more convenient for you likely depends on the source of your data, as described below.

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:

    {
        markers: [
            { "MarkersHeader1": ..., "MarkersHeader2": ..., ... },
            { "MarkersHeader1": ..., "MarkersHeader2": ..., ... },
            { "MarkersHeader1": ..., "MarkersHeader2": ..., ... },
            ...
        ],
        icons: [
            { "IconsHeader1": ..., "IconsHeader2": ..., ... },
            { "IconsHeader1": ..., "IconsHeader2": ..., ... },
            { "IconsHeader1": ..., "IconsHeader2": ..., ... },
            ...
        ],
        regions: [
            { "RegionsHeader1": ..., "RegionsHeader2": ..., ... },
            { "RegionsHeader1": ..., "RegionsHeader2": ..., ... },
            { "RegionsHeader1": ..., "RegionsHeader2": ..., ... },
            ...
        ]
    }

... but with the keys being the column headers from your source data instead. To tell the API how these 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: "_784",
    version: "_4",
    bindings: {
        markers: {
            lat: "MarkersHeader1",
            long: "MarkersHeader2"
        },
        icons: {
            category_name: "IconsHeader1",
            icon: "IconsHeader2"
        },
        regions: {
            
        }
    },
    data: {
        markers: [
            { "MarkersHeader1": ..., "MarkersHeader2": ..., ... },
            { "MarkersHeader1": ..., "MarkersHeader2": ..., ... },
            { "MarkersHeader1": ..., "MarkersHeader2": ..., ... },
            ...
        ],
        icons: [
            { "IconsHeader1": ..., "IconsHeader2": ..., ... },
            { "IconsHeader1": ..., "IconsHeader2": ..., ... },
            { "IconsHeader1": ..., "IconsHeader2": ..., ... },
            ...
        ],
        regions: [
            { "RegionsHeader1": ..., "RegionsHeader2": ..., ... },
            { "RegionsHeader1": ..., "RegionsHeader2": ..., ... },
            { "RegionsHeader1": ..., "RegionsHeader2": ..., ... },
            ...
        ]
    }
}

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

{
    template: "_784",
    version: "_4",
    bindings: {
        markers: {
            lat: "MarkersHeader1",
            long: "MarkersHeader2",
            category: "MarkersHeader3",
            name: "MarkersHeader4",
            description: "MarkersHeader5",
            image: "MarkersHeader6",
            color: "MarkersHeader7",
            link: "MarkersHeader8",
            size: "MarkersHeader9",
            metadata: ["MarkersHeader10", "MarkersHeader11", ...]
        },
        icons: {
            category_name: "IconsHeader1",
            icon: "IconsHeader2",
            size: "IconsHeader3",
            color: "IconsHeader4",
            opacity: "IconsHeader5"
        },
        regions: {
            geojson: "RegionsHeader1"
        }
    },
    data: {
        markers: [
            { "MarkersHeader1": ..., "MarkersHeader2": ..., ... },
            { "MarkersHeader1": ..., "MarkersHeader2": ..., ... },
            { "MarkersHeader1": ..., "MarkersHeader2": ..., ... },
            ...
        ],
        icons: [
            { "IconsHeader1": ..., "IconsHeader2": ..., ... },
            { "IconsHeader1": ..., "IconsHeader2": ..., ... },
            { "IconsHeader1": ..., "IconsHeader2": ..., ... },
            ...
        ],
        regions: [
            { "RegionsHeader1": ..., "RegionsHeader2": ..., ... },
            { "RegionsHeader1": ..., "RegionsHeader2": ..., ... },
            { "RegionsHeader1": ..., "RegionsHeader2": ..., ... },
            ...
        ]
    }
}

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

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: "_784",
version: "_4",
data: {
    markers: [
        {
            lat: ...,
            long: ...,
            metadata: [...]
        },
        ...
    ],
    icons: [
        {
            category_name: ...,
            icon: ...
        },
        ...
    ]
},
...
}

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

{
template: "_784",
version: "_4",
data: {
    markers: [
        {
            lat: ...,
            long: ...,
            category: ...,
            name: ...,
            description: ...,
            image: ...,
            color: ...,
            link: ...,
            size: ...,
            metadata: [...]
        },
        ...
    ],
    icons: [
        {
            category_name: ...,
            icon: ...,
            size: ...,
            color: ...,
            opacity: ...
        },
        ...
    ],
    regions: [
        {
            geojson: ...
        },
        ...
    ]
},
...
}

Meanings of the template data keys:

  • markers.lat: lat
  • markers.long: long
  • markers.category: Category of place. Values should match the 'Category' column in the Icon styles sheet.
  • markers.name: Name of place, shown in popup
  • markers.description: Description of place, shown in popup
  • markers.image: Image, shown in popup
  • markers.color: Colour of the icon - this can be a hex value like '#fff', or a web-safe value like 'red'. Note that this is only available when using Font Awesome icons.
  • markers.link: Link to open when marker is clicked; works when published but not in the editor
  • markers.size: size
  • markers.metadata: Extra metadata to show in the popup. Add as many columns as you like
  • icons.category_name: Values should match the 'Category' column in the Places sheet, and should not be repeated.
  • icons.icon: The image for the marker. Can be a Font Awesome icon name, e.g. 'circle' or 'chevron-right'; a D3 SVG icon name, e.g. 'd3-star' or 'd3-cross'; an image URL; or an emoji.
  • icons.size: Amount to scale the icon by.
  • icons.color: Colour of the icon - this can be a hex value like '#fff', or a web-safe value like 'red'. Note that this is only available when using Font Awesome icon names.
  • icons.opacity: Opacity of the icon between 0 and 1, e.g. 0.5
  • regions.geojson: geojson

Template settings

Options for opts.state.

Base map

map.style_base string

Map style.

Allowed values:

  • dark-matter (Dark Matter)
  • positron (Positron)
  • osm-bright (OSM Bright)
  • klokantech-basic (Klokantech Basic)
  • klokantech-3d (Klokantech 3D)
  • klokantech-terrain (Klokantech Terrain)
  • fiord-color (Fiord)
  • toner (Toner)

map.style_show_labels boolean

Display labels.

map.map_zoom_min number

Min. zoom.

Max: 22

map.map_zoom_max number

Max. zoom.

Max: 22

map.map_bound_position boolean

Limit viewport bounds.

map.map_lat_min number

Min. Latitude.

Min: -90

Max: 90

map.map_lat_max number

Max. Latitude.

Min: -90

Max: 90

map.map_lng_min number

Min. Longitude.

Min: -180

Max: 180

map.map_lng_max number

Max. Longitude.

Min: -180

Max: 180

map.map_interactive boolean

Allow user interaction.

map.map_hijack_scroll boolean

Require cmd/ctrl to zoom when scrolling.

map.controls_geolocator_enabled boolean

Use geolocator control.

map.controls_geolocator_alignment string

Geolocator control position.

Allowed values:

  • top-left (Top left)
  • top-right (Top right)
  • bottom-left (Bottom left)
  • bottom-right (Bottom right)

map.controls_fullscreen_enabled boolean

Use fullscreen control.

map.controls_fullscreen_alignment string

Fullscreen control position.

Allowed values:

  • top-left (Top Left)
  • top-right (Top Right)
  • bottom-left (Bottom Left)
  • bottom-right (Bottom Right)

Inset map

minimap.minimap_display boolean

Display map.

minimap.minimap_rotate boolean

Rotate with camera.

minimap.minimap_custom_colors boolean

Customise colours.

minimap.minimap_fill color

Region fill color.

minimap.minimap_ocean_color color

Ocean color.

minimap.minimap_stroke color

Region stroke color.

minimap.minimap_outline color

Outline color.

minimap.minimap_show_bounds boolean

Display viewport bounds.

minimap.minimap_bounds_color color

Region bounds color.

minimap.minimap_bounds_opacity number

Region bounds opacity.

Max: 1

Icons

icon_scale number

Scale.

Max: 100

icon_default_icon url

Icon. Can be an emoji, icon code or image; used for any icons that don't have an icon in the data

icon_default_opacity number

Opacity.

Max: 1

icon_default_color color

Colour.

Labels

label_size number

Label size.

label_offset number

Label offset.

label_autohide boolean

Hide overlapping labels.

label_custom_style boolean

Customise label style.

label_color color

Label color.

label_halo_color color

Halo color.

label_halo_width number

Halo width.

label_halo_blur number

Halo blur.

Popups

popup.show_popups boolean

Popups.

Allowed values:

  • true (Enabled)
  • false (Disabled)

popup.is_custom boolean

Popup contents.

Allowed values:

  • false (Auto)
  • true (Custom content)

popup.custom_template text

Popup content. The text to appear in the popup. You can use {{column_name}} to add a value from your data. It must be in a selected column, but you can add columns to “Metadata” if you just want to include them for use in the popup. Advanced users can include HTML to apply layouts, formatting, images, etc.

popup.show_pointer boolean

Pointer.

popup.show_shadow boolean

Shadow.

popup.style_popups boolean

Custom styling.

popup.text_color color

Text colour.

popup.align string

Alignment.

Allowed values:

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

popup.font_size number

Font size.

Min: 1

popup.fill_color color

Fill colour.

popup.opacity number

Fill opacity.

Max: 1

popup.padding number

Padding.

popup.border_radius number

Radius. Corner radius of popup