Using the BRC Atlas Library

Create a map from a div tag

The simplest way to use the brcatlas library to put a map in a web page is use a div tag with data attributes to display a prepared CSV file.

First include the required Javascript libraries and CSS in the page. We need the BRC Atlas JS libary, the associated CSS and the D3 library which is an external external dependency of the BRC Atlas library. In this example they are all included from CDNs.

    <script src="https://d3js.org/d3.v7.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/biologicalrecordscentre/brc-atlas/dist/brcatlas.umd.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/biologicalrecordscentre/brc-atlas/dist/brcatlas.umd.css"></script>
    

Now you can create a map like this:

      <div id="ex1" class="brcatlas" data-csv="example-hectads-1.csv"></div>
    

This is what you see:

The div should include a unique id, the class brcaltas and, if you want to display some data, the data-csv attribute pointing to a correctly formatted CSV file (see below). This normally this CSV file would sit somewhere on your website's server.

The CSV file should have the column headers shown in the table below.

grshapecolouropacitysize
HU58circlered11
J33square#5eeb340.80.9
WA50triangle-upgreen0.50.7
SC37triangle-upgreen11
SE68triangle-downgreen11
SD64diamondgreen11

The order of the columns is not important. Note the following:

You can also display CSV files containing either tetrads (2x2 km) or monads (1x1 km). If you do this, you must include the 'data-precision' attribute and set it to either 2000 for tetrads or '1000' for monads.

On the static map there is an options symbol at the bottom-right of the map that, when clicked, invokes a dialog where the user can change the appearance of the map by selecting a view with or without 'insets' for the Northern Isles and Channel Islands. You can remove this symbol by specifying 'data-opts="false"'. You can also specify which of the four display options you want to initialise the map with by specifying the 'data-trans' option. You can set it to one of the following options:

      <div 
    id="ex2" 
    class="brcatlas" 
    data-csv="example-hectads-1.csv"
    data-opts="false"
    data-trans="BI4"
></div>
    

The default map is a 'static', map of the type shown above, but you can also create a slippy (Leaflet) map by specifying 'data-slippy="true"'.

<div 
    id="ex3" 
    class="brcatlas" 
    data-csv="example-hectads-1.csv"
    data-slippy="true"
></div>
    

Note that to create the slippy map, you will need to include the Leaflet libraries:

      <script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"></script>
    

Change the size of the map with the 'data-height' and 'data-width' attributes. Note that for static map, width is calculated automatically from the height, so you only need to specify height for that type of map.

<div 
    id="ex4" 
    class="brcatlas" 
    data-csv="example-hectads-1.csv"
    data-slippy="true"
    data-width="700"
    data-height="400"
></div>
    

You can also specify a legend to be displayed on the map. Obviously this should reflect the colours, shapes, opacity etc that you used for the dots in the CSV (though it doesn't in the example below).

      <div 
    id="ex5" 
    class="brcatlas" 
    data-csv="example-hectads-1.csv"
    data-height="500"
    data-trans="BI4"
    data-legend="true"
    data-legend-title="This is my legend"
    data-legend-lines="Blah; circle; red | Blah blah; circle; magenta | Blah blah blah; circle; green"
    data-legend-x="10"
    data-legend-y="10"
    data-legend-scale="0.8"
    data-legend-opacity="0.8"
></div>
    

The 'data-legend' must be set to 'true' to display any sort of legend. Use 'data-legend-title' to specify a title for the legend. Use 'data-legend-lines' to specify the individual lines in legend. Each line should be separated with the '|' (pipe) character. Then each line consists of a string of the format 'caption; shape; colour'. Shape and colour use the same values as can be used in the CSV file (see above). The 'data-legend-x' and 'data-legend-y' attributes can be used to specify and offset from the left and top margins of the map. The attribute 'data-legend-scale' specifies a number between 0 and 1 used to scale the entire lagend - useful if it is too big for the map. The attribute 'data-legend-opacity' should be set to a value between 0 and 1 which specifies and the overall opacity of the legend.