View on GitHub

brc-atlas

Javascript library for web-based biological records atlas mapping in the British Isles

BRC Atlas library

The BRC Atlas library is a Javascript library for providing both easy and flexible APIs for creating static and slippy maps for atlas projects. In fact there are two libraries packaged in one project - one for British atlas mapping (brcatlas.umd.js) and one for European atlas mapping (brcatlas_e.umd.js).

Installing

You can get the javscript amd css builds from the GitHub repo or include them in code directly from a CDN, e.g:

<script src="https://cdn.jsdelivr.net/gh/biologicalrecordscentre/brc-atlas/dist/brcatlas.umd.js"></script>

or a minified version generated by the CDN:

<script src="https://cdn.jsdelivr.net/gh/biologicalrecordscentre/brc-atlas/dist/brcatlas.umd.min.js"></script>

You will also need to inlcude the associated CSS, e.g:

<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/biologicalrecordscentre/brc-atlas/dist/brcatlas.umd.css">

or a minified version generated by the CDN:

<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/biologicalrecordscentre/brc-atlas/dist/brcatlas.umd.min.css">

The CDN also exposes some geojson assets. These are used internally by the mapping libraries, but can be used independently. They include:

API documentation and code examples

For details of the API, view the JSDoc API documentation.

There are also a number of working examples.

Notes for developers

Installing to development environment

This project is configured as a Node project. To install and run it in a local development environment you will first need to install Node and the Node Package Manager (npm) on your computer. Then clone the repository from GitHub and in the root project folder run npm install. That will install all the Node package dependencies into a folder called ‘node_modules’. Note that this large folder should not be committed to the repository - hece a line in the root .gitignore folder to exclude it.

Assets

There are a number of geojson files in the assets folder. These are loaded by the code when needed. In the development environment, it will often be the case that these assets need to be loaded from the local environment but in the live environment, they need to be loaded from the CDN. You can edit the code in src/constants.hs & src_e/e_constants.js, as indicated by inline comments, to make sure the assets are being loaded correctly.

Documentation

The package uses JSDoc to produce the API documentation. JSDoc is not included in the package dependendies since developers normally install it globally in their development environment.

Two libraries in one package

There are two libraries in this package:

Although these libraries are bundled here in the same package, they are essentially different projects without any interdependendies.

Typical build & publish workflow

Rollup

Rollup is used to build the transpiled library javascript assets for this package. Rollup is often preferred over webpack or other bundling tools for packaging libraries. The following javascript assets are produced by this rollup configuration:

The following rollup plugins are used in the build:

Other files in project

The following files are in the root folder: