---
title: "MaplibreMigration"
description: "迁徙图，OD 对生成贝塞尔弧线，粒子沿线循环飞行并带渐变尾迹。"
canonical_url: "https://maplibre.mhaibaraai.cn/docs/effects/migration"
---
# MaplibreMigration

> 迁徙图，OD 对生成贝塞尔弧线，粒子沿线循环飞行并带渐变尾迹。

## 简介

`MaplibreMigration` 由起讫点对（`data` 为 `{ from, to }` 列表）生成贝塞尔弧线，粒子沿线循环飞行并带渐变尾迹；`color` / `curvature` / `duration` / `lineWidth` / `particleRadius` 控制外观与节奏。

## 用法

切换主色查看自北京出发的迁徙航线：

```vue [MigrationExample.vue]
<script setup lang="ts">
withDefaults(defineProps<{ color?: string }>(), {
  color: '#f43f5e'
})

// 自北京出发的迁徙航线
const routes: { from: [number, number], to: [number, number] }[] = [
  { from: [116.40, 39.90], to: [121.47, 31.23] },
  { from: [116.40, 39.90], to: [113.26, 23.13] },
  { from: [116.40, 39.90], to: [104.07, 30.67] },
  { from: [116.40, 39.90], to: [87.62, 43.79] }
]
</script>

<template>
  <div class="h-115 w-full overflow-hidden rounded-(--ui-radius) border border-default">
    <MaplibreMap :options="{ style: 'https://tiles.openfreemap.org/styles/dark', center: [104, 36], zoom: 3.2 }">
      <MaplibreMigration :data="routes" :color="color" />
    </MaplibreMap>
  </div>
</template>
```

## API

### Props

```ts
/**
 * Props for the MaplibreMigration component
 */
interface MaplibreMigrationProps {
  /**
   * 起讫点对列表
   */
  data: MigrationRoute[];
  /**
   * 图层 id 前缀；省略时自动生成，变更需配合 `:key` 重建
   */
  layerId?: string | undefined;
  /**
   * 主色
   * @default '#f43f5e'
   */
  color?: string | undefined;
  /**
   * 弧线弯曲程度
   * @default 0.3
   */
  curvature?: number | undefined;
  /**
   * 单程飞行周期（毫秒）
   * @default 3000
   */
  duration?: number | undefined;
  /**
   * 线宽（像素）
   * @default 2
   */
  lineWidth?: number | undefined;
  /**
   * 粒子半径（像素）
   * @default 4
   */
  particleRadius?: number | undefined;
  /**
   * 插入到该图层之前
   */
  beforeId?: string | undefined;
}
```

## Changelog

See commit history for [src/runtime/components/effects/Migration.vue](https://github.com/mhaibaraai/movk-maplibre/commits/main/src/runtime/components/effects/Migration.vue).


## Sitemap

See the full [sitemap](https://maplibre.mhaibaraai.cn/sitemap.md) for all pages.
