2.3.8 • Published 2 years ago
leaflet.migration v2.3.8
leaflet.migration
leaflet plugin that provides migration lines layer.
Installation
npm install -S leaflet.migration
Demo
import L from 'leaflet';
import 'leaflet/dist/leaflet.css';
import 'leflet.migration';
const data = [
{
labels: ['from', 'to'],
from: [lat, lng],
to: [lat, lng],
color: '',
value: '',
},
];
const popover = document.querySelector('.popover');
const options = {
marker: {
radius: [5, 10],
pulse: true,
textVisible: true
},
line: {
width: 1,
order: false,
icon: {
type: 'arrow',
imgUrl: '',
size: 20
},
},
// marker: 'https://github.githubassets.com/favicons/favicon.png',
replacePopover(x, y, data, index) {
console.log(x, y, data, index, 'replace popover');
popover.innerHTML =
'value:' + data.value + '\nfrom:' + data.labels[1] + '\nto:' + data.labels[0];
return popover;
},
onShowPopover(data, index) {
console.log(data, index, 'show popover');
},
onHidePopover(data) {
console.log('hide popover', data);
},
};
const migrationLayer = L.migrationLayer(data, options);
migrationLayer.setStyle({ pulse: { radius: 20 } });
migrationLayer.setData([]);
map.remove(migrationLayer);
API
Data
type | description |
---|---|
[<MigrationData>] | migration data list |
MigrationData
name | type | description |
---|---|---|
labels | [<string>from, <string> to] | label |
from | [<number>lat, <number>lng] | from label latlng |
to | [<number>lat, <number>lng] | to label latlng |
color | string | the color of each arc and pulse |
value | number | intense value of migration line |
Options
name | type | default | description |
---|---|---|---|
marker | MarkerOption | - | marker style |
line | LineOption | - | line style |
minZoom | number | 3 | migration layer display when zoom >= 3 |
replacePopover | (<pixel>x , <pixel>y , <MigrationData>data , <integer>index ) => Element | - | replace default popover by return element |
onShowPopover | (<MigrationData>data , <integer>index ) => void | - | called on mouse hover pulse |
onHidePopover | (<integer>index ) => void | none | called on mouse leave pulse |
MarkerOption
name | type | default | description |
---|---|---|---|
radius | [<number>min, <number> max] | 5, 10 | marker size range, measure by MigrationData.value |
pulse | boolean | true | marker's ring animation |
textVisible | boolean | false | whether marker label |
LineOption | name | type | default | description | | ---- | ---- | ------- | ----------- | | width | number | 1 | migration line width | | order | boolean | false | whether the sweep run in sequence | | icon | LineIcon | { type: 'circle', size: 20 } | sweep header style |
LineIcon
name | type | default | description |
---|---|---|---|
type | circle|arrow|img | circle | icon type |
imgUrl | string | - | Image url when type is img |
size | number | 20 | icon size |
Methods
method | returns | descrition |
---|---|---|
setData([<MigrationData>] ) | this | update migration data |
setStyle(options) | this | update style |
show() | this | show layer |
hide() | this | hide layer |
play() | this | run animate of arc and pulse |
pause() | this | pause animate of arc and pulse |
Methods inherited from L.Layer
method | returns | descrition |
---|---|---|
onAdd(<Map> map ) | this | called on L.migrationLayer(data, style).addTo(map) |
onRemove(<Map> map ) | this | called on map.remove(migrationLayer) |
Requirements
- leaflet ^1.8.0
- node ^14.17.3
2.3.6
2 years ago
2.3.5
2 years ago
2.3.8
2 years ago
2.3.7
2 years ago
2.3.0
2 years ago
2.3.2
2 years ago
2.3.1
2 years ago
2.3.4
2 years ago
2.3.3
2 years ago
2.2.0
4 years ago
2.1.1
4 years ago
2.1.0
4 years ago
2.0.5
5 years ago
2.0.4
5 years ago
2.0.3
5 years ago
2.0.2
5 years ago
2.0.1
5 years ago
2.0.0
6 years ago
1.0.10
6 years ago
1.0.9
6 years ago
1.0.8
6 years ago
1.0.7
6 years ago
1.0.6
6 years ago
1.0.5
6 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.0
6 years ago