---
title: "MapboxMigration"
description: "迁徙图，OD 对生成贝塞尔弧线，粒子沿线循环飞行并带渐变尾迹。"
seo_title: "MapboxMigration Component"
seo_description: "Migration effect drawing bezier arcs from origin-destination pairs with particles flying along gradient trails."
canonical_url: "https://mapbox.mhaibaraai.cn/docs/effects/migration"
---
# MapboxMigration

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

## 简介

`MapboxMigration` 由起讫点对（`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">
    <MapboxMap :options="{ style: 'mapbox://styles/mapbox/dark-v11', center: [104, 36], zoom: 3.2 }">
      <MapboxMigration :data="routes" :color="color" />
    </MapboxMap>
  </div>
</template>
```

## API

### Props

```ts
/**
 * Props for the MapboxMigration component
 */
interface MapboxMigrationProps {
  /**
   * 起讫点对列表
   */
  data: MigrationRoute[];
  /**
   * 图层 id 前缀；省略时自动生成
   */
  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-mapbox/commits/main/src/runtime/components/effects/Migration.vue).


## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
