2.2.10 • Published 3 years ago

wgis.leaflet.migration.vue2 v2.2.10

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

leaflet.migration

原版本:https://github.com/lin-123/leaflet.migration 魔改版:扫尾点变成1 leaflet plugin that provides migration lines layer.

alt text

Installation

npm install -S leaflet.migration

Rquirements

  • leaflet ^1.5.1
  • node 10.8.0

Usage

import 'leflet.migration';
const data = [{
  labels: ['from', 'to'],
  from: [lat, lng],
  to: [lat, lng],
  color: '',
  value: ''
}];
var options = {
  minRadius: 3,
  maxRadius: 3,
  arcWidth: 0.001,
  label: true,
  order: true,
  replacePopover: function (x, y, data, index) {
    console.log(x, y, data, index, 'show popover');
    popover.innerHTML = 'value:' + data.value + '\nfrom:' + data.labels[1] + '\nto:' + data.labels[0]
    return popover;
  },
  onShowPopover: function (x, y, data, index) {
    console.log(x, y, data, index, 'show popover');
  },
  onHidePopover: function (index) {
    console.log('hide popover', index);
  }
};
var migrationLayer = L.migrationLayer(data.map(i => Object.assign(i, {  })), options);
migrationLayer.setStyle({ pulse: { radius: 20 }})
migrationLayer.setData([])
map.remove(migrationLayer)

API

Data

typedescription
[<MigrationData>]migration data list

MigrationData

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

Options|Style

optiontypedefaultdescription
minRadiusnumber5pulse min radius
maxRadiusnumber2*minRadiuspulse max radius
arcWidthnumber1arc border width
labelbooleantrueset it to false if you don't want show label
orderbooleanfalseTrack animation sequence execution

Options|EventHandler

methodreturnsdescription
replacePopover(<pixel>x, <pixel>y, <MigrationData>data, <integer>index)Elementreplace default popover by return element
onShowPopover(<MigrationData>data, <integer>index)nonecalled on mouse hover pulse
onHidePopover(<integer>index)nonecalled on mouse leave pulse

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)

Development

TODO

  • [] 渲染性能优化, 可以支持上万个点同时运动
    • 提前把各个扫尾的点的下一个位置计算好, 然后调用 canvas redraw

feature list

2.2.0

  • options新增了一个order参数,可以控制轨迹动画是否按顺序播放

2.1.0

  • 更新 option 参数, 原 pulseRadius 改成 minRadius, maxRadius;

2.0.5

  • fix bug: popover 由于 map 元素相对页面左上角的偏移而出现偏移 label 元素较远

2.0.4

  • fix spark not work when Math.abs(startAngle - endAngle) > Math.PI

2.0.1

  • fix spark cannot move

2.0.0

  • accomplish setData/setStyle
  • accomplish addTo and remove function
  • update init options
  • add demo to gh-pages
  • customize popover

1.1.0

  • update return value of new MigrationLayer()

1.0.3

  • set pulse size by data value, radius, zoom

1.0.0

  • add webpack
  • add popover
  • config data, style
  • layer.setData
2.2.10

3 years ago

2.2.9

3 years ago

2.2.8

3 years ago

2.2.7

3 years ago

2.2.6

3 years ago

2.2.3

3 years ago

2.2.2

3 years ago

2.2.5

3 years ago

2.2.4

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago