2.3.8 • Published 2 years ago

leaflet.migration v2.3.8

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

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

typedescription
[<MigrationData>]migration data list

MigrationData

nametypedescription
labels[<string>from, <string> to]label
from[<number>lat, <number>lng]from label latlng
to[<number>lat, <number>lng]to label latlng
colorstringthe color of each arc and pulse
valuenumberintense value of migration line

Options

nametypedefaultdescription
markerMarkerOption-marker style
lineLineOption-line style
minZoomnumber3migration 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) => voidnonecalled on mouse leave pulse

MarkerOption

nametypedefaultdescription
radius[<number>min, <number> max]5, 10marker size range, measure by MigrationData.value
pulsebooleantruemarker's ring animation
textVisiblebooleanfalsewhether 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

nametypedefaultdescription
typecircle|arrow|imgcircleicon type
imgUrlstring-Image url when type is img
sizenumber20icon size

Methods

methodreturnsdescrition
setData([<MigrationData>])thisupdate migration data
setStyle(options)thisupdate style
show()thisshow layer
hide()thishide layer
play()thisrun animate of arc and pulse
pause()thispause animate of arc and pulse

Methods inherited from L.Layer

methodreturnsdescrition
onAdd(<Map> map)thiscalled on L.migrationLayer(data, style).addTo(map)
onRemove(<Map> map)thiscalled 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