Leaflet Flow Map
LeafletFlowMap is an extension of LeafletMap that can display flying particles between two points on the map. Particles will be rendered on a separate three.js canvas on top of the base map. LeafletFlowMap has the same configuration ope as LeafletMap with a few extra properties related to the particles.
- React
- Angular
- Svelte
- Vue
- TypeScript
<VisLeafletFlowMap style={style} data={data}/>
<vis-leaflet-flow-map
[style]="style"
[data]="data"
></vis-leaflet-flow-map>
<VisLeafletFlowMap {style} {data}/>
<VisLeafletFlowMap :style="style" :data="data" />
const leafletFlowMap = new LeafletFlowMap<MapPointRecord, MapFlowRecord>(node, {
style
}, data)
Data
LeafletFlowMap expects the data to be an object with points
and flows
arrays:
type LeafletMapData = {
points: MapPointRecord[];
flows: MapFlowRecord[];
}
The points
array corresponds to regular LeafletMap points. The flows
array should contain
information about source and target coordinates of the flying particles. By default, LeafletFlowMap expects the following
data format:
type MapFlowRecord = {
sourceLongitude: number;
sourceLatitude: number;
targetLongitude: number;
targetLatitude: number;
}
You can also use custom accessor functions to get the source and target coordinates of the particles by providing them to
the following configuration options: sourceLatitude
, sourceLongitude
, targetLatitude
, targetLongitude
.
Particles
LeafletFlowMap allows to change the appearance of the flying particles by providing either constant values or accessor functions (that will be executed per flow) to the configuration attributes specified below.
Color
The color of the particles can be set by using the flowParticleColor
property:
- React
- Angular
- Svelte
- Vue
- TypeScript
<VisLeafletFlowMap style={style} flowParticleColor="#f00" data={data}/>
<vis-leaflet-flow-map
[style]="style"
flowParticleColor="#f00"
[data]="data"
></vis-leaflet-flow-map>
<VisLeafletFlowMap {style} flowParticleColor="#f00" {data}/>
<VisLeafletFlowMap
:style="style"
flowParticleColor="#f00"
:data="data"
/>
const leafletFlowMap = new LeafletFlowMap<MapPointRecord, MapFlowRecord>(node, {
style,
flowParticleColor: "#f00"
}, data)
Radius
You can chance the radius of the particles with the flowParticleRadius
property:
- React
- Angular
- Svelte
- Vue
- TypeScript
<VisLeafletFlowMap style={style} flowParticleRadius={10} data={data}/>
<vis-leaflet-flow-map
[style]="style"
[flowParticleRadius]="10"
[data]="data"
></vis-leaflet-flow-map>
<VisLeafletFlowMap {style} flowParticleRadius={10} {data}/>
<VisLeafletFlowMap
:style="style"
:flowParticleRadius="10"
:data="data"
/>
const leafletFlowMap = new LeafletFlowMap<MapPointRecord, MapFlowRecord>(node, {
style,
flowParticleRadius: 10
}, data)
Speed
The speed of the particles can be controlled by using the flowParticleSpeed
property. The value is in arbitrary angular
units, we recommend it to be in the range of [0,0.2].
- React
- Angular
- Svelte
- Vue
- TypeScript
<VisLeafletFlowMap style={style} flowParticleSpeed={0.02} data={data}/>
<vis-leaflet-flow-map
[style]="style"
[flowParticleSpeed]="0.02"
[data]="data"
></vis-leaflet-flow-map>
<VisLeafletFlowMap {style} flowParticleSpeed={0.02} {data}/>
<VisLeafletFlowMap
:style="style"
:flowParticleSpeed="0.02"
:data="data"
/>
const leafletFlowMap = new LeafletFlowMap<MapPointRecord, MapFlowRecord>(node, {
style,
flowParticleSpeed: 0.02
}, data)
Density
The flowParticleDensity
property can be used to set the density / frequency of the flying particles. The recommended
range is [0, 3].
- React
- Angular
- Svelte
- Vue
- TypeScript
<VisLeafletFlowMap style={style} flowParticleDensity={2} data={data}/>
<vis-leaflet-flow-map
[style]="style"
[flowParticleDensity]="2"
[data]="data"
></vis-leaflet-flow-map>
<VisLeafletFlowMap {style} flowParticleDensity={2} {data}/>
<VisLeafletFlowMap
:style="style"
:flowParticleDensity="2"
:data="data"
/>
const leafletFlowMap = new LeafletFlowMap<MapPointRecord, MapFlowRecord>(node, {
style,
flowParticleDensity: 2
}, data)
Flow Source Points
Similarly, you can change how the source points will look.
Color
The color of the flow source can be customized by using the sourcePointColor
configuration property:
- React
- Angular
- Svelte
- Vue
- TypeScript
<VisLeafletFlowMap
style={style}
sourcePointColor="#4A46B5"
data={data}
/>
<vis-leaflet-flow-map
[style]="style"
sourcePointColor="#4A46B5"
[data]="data"
></vis-leaflet-flow-map>
<VisLeafletFlowMap {style} sourcePointColor="#4A46B5" {data}/>
<VisLeafletFlowMap
:style="style"
sourcePointColor="#4A46B5"
:data="data"
/>
const leafletFlowMap = new LeafletFlowMap<MapPointRecord, MapFlowRecord>(node, {
style,
sourcePointColor: "#4A46B5"
}, data)
Radius
The sourcePointRadius
property sets the radius of the source point:
- React
- Angular
- Svelte
- Vue
- TypeScript
<VisLeafletFlowMap style={style} sourcePointRadius={5} data={data}/>
<vis-leaflet-flow-map
[style]="style"
[sourcePointRadius]="5"
[data]="data"
></vis-leaflet-flow-map>
<VisLeafletFlowMap {style} sourcePointRadius={5} {data}/>
<VisLeafletFlowMap
:style="style"
:sourcePointRadius="5"
:data="data"
/>
const leafletFlowMap = new LeafletFlowMap<MapPointRecord, MapFlowRecord>(node, {
style,
sourcePointRadius: 5
}, data)
Events
The flow source points have the following configurable callback functions for mouse events:
/** Flow source point click callback function. Default: `undefined` */
onSourcePointClick: (f: FlowDatum, x: number, y: number, event: MouseEvent) => void;
/** Flow source point mouse over callback function. Default: `undefined` */
onSourcePointMouseEnter: (f: FlowDatum, x: number, y: number, event: MouseEvent) => void;
/** Flow source point mouse leave callback function. Default: `undefined` */
onSourcePointMouseLeave: (f: FlowDatum, event: MouseEvent) => void;
Component Props
Name | Type | Description |
---|---|---|
* required property |