gatsby-strava-declutter
v0.3.1
Published
Gatsby plugin to draw each road of your Strava activities only once on a map
Maintainers
Readme
Gatsby plugin that draws each road of your Strava activities only once on a map
Drawing every track of a long Strava history gives a map of blobs. This plugin cuts the parts of a track following a road already drawn, so that zoomed in every street you went through is drawn once, and zoomed out the lines stay as fine and as far apart everywhere, however many times you went through a place.
| With declutter | Without declutter |
| ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
|
|
|
|
Usage
- Download gatsby-source-strava and
gatsby-strava-declutterfrom the NPM registry:
npm install gatsby-source-strava gatsby-strava-declutter- Add both plugins in your
gatsby-config.jsfile
require("dotenv").config()
module.exports = {
plugins: [
"gatsby-source-strava", // MANDATORY
//
// It MUST be after `gatsby-source-strava`
"gatsby-strava-declutter",
],
}gatsby-source-strava needs
clientId,clientSecretandtokenoptions to works.Checkout documentation.
Options
| Option | Default | What it is |
| ---------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| filter | every activity kept | (activity) => boolean, the StravaActivity nodes to compare |
| minZoom | 6 | The lowest zoom generalized, the lower ones draw its lines |
| maxZoom | 12 | The highest zoom generalized, the full tracks show from the next one |
| storeDir | ".strava-declutter" | Where the result is kept between builds, see Store |
Data
The plugin adds a declutter field to the StravaActivity nodes: whether the
activity is drawn, the pieces of its track drawn at every zoom, and the pieces
that depend on the zoom.
Read the declutter documentation for the options, the full field reference, and how to draw it with Mapbox or MapLibre.
Functions
The logic of the plugin lives in strava-declutter, which
works without Gatsby too. The declutter and the track simplification can be
called from your own gatsby-node.js:
const {declutter, simplify} = require("gatsby-strava-declutter")To read the declutter of an activity in your own gatsby-node.js, get its
Declutter node:
const {getDeclutterNodeId} = require("gatsby-strava-declutter")
const declutterNode = getNode(getDeclutterNodeId(activityNode.id))