1.0.1 • Published 2 years ago

leaflet-streamlines v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Leaflet Streamlines

npm version

Visualise two dimensional vector fields in leaflet using stream lines.

Image of Leaflet Streamlines

Grid of simulated water velocity values on Lake Geneva from the Meteolakes project, plotted as streamlines.

Check out the examples:

This project is inspired by earth and borrows code from the IH.Leaflet.CanvasLayer.Field project.

Quick start

import L from "leaflet";
import 'leaflet-streamlines';

or

<link
    rel="stylesheet"
    href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
    integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
    crossorigin=""
/>
<script
    src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
    integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
    crossorigin=""
></script>
<script type="text/javascript" src="https://unpkg.com/leaflet-streamlines"></script>

then

var map = L.map("map");
L.streamlines(data, options).addTo(map);

API reference

data

Data must be an object {u: [[]], v:[[]]} where u and v are 2D arrays of equivalent shape. u: y veloctiy (northward) v: x veloctiy (eastward)

options

OptionDescriptionDefaultType
xMax (Required)Maximum x coordinateNumber
xMin (Required)Minimum x coordinateNumber
yMax (Required)Maximum y coordinateNumber
yMin (Required)Minimum y coordinateNumber
pathsNumber of streamlines to plot800Number
colorColor of streamlines, either a html color ("white", #FF5733) or a function that returns a color based on a single input of velocity magnitude.whiteCustom
widthWidth of the streamline0.5Number
fadeControl the streamline fade0.97Number
durationMilliseconds between timesteps10Number
maxAgeMax number of timesteps for streamline50Number
velocityScaleFactor to toggle speed of streamlines0.01Number
opacityOpacity of streamlines1Number