---
title: "MapboxRadar"
description: "雷达扫描效果，canvas 生成扇形扫描贴图并按帧旋转。"
seo_title: "MapboxRadar Component"
seo_description: "Radar sweep effect rendering a canvas-generated sector image rotated per frame over point features."
canonical_url: "https://mapbox.mhaibaraai.cn/docs/effects/radar"
---
# MapboxRadar

> 雷达扫描效果，canvas 生成扇形扫描贴图并按帧旋转。

## 简介

`MapboxRadar` 在点要素上渲染雷达扫描：canvas 生成扇形扫描贴图，symbol 图层按帧旋转；`color` / `radius` / `speed` 控制颜色、扫描半径与转速。

## 用法

调整 `speed`（度/秒）观察扫描转速：

```vue [RadarExample.vue]
<script setup lang="ts">
import type { FeatureCollection } from 'geojson'

withDefaults(defineProps<{ speed?: number }>(), {
  speed: 120
})

const data: FeatureCollection = {
  type: 'FeatureCollection',
  features: [
    { type: 'Feature', properties: {}, geometry: { type: 'Point', coordinates: [116.397, 39.908] } },
    { type: 'Feature', properties: {}, geometry: { type: 'Point', coordinates: [116.46, 39.92] } }
  ]
}
</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: [116.43, 39.913], zoom: 11 }">
      <MapboxRadar :data="data" :speed="speed" color="#22c55e" />
    </MapboxMap>
  </div>
</template>
```

## API

### Props

```ts
/**
 * Props for the MapboxRadar component
 */
interface MapboxRadarProps {
  /**
   * 点要素数据（GeoJSON 或其 URL）
   */
  data: string | GeoJSON.GeoJSON<GeoJSON.Geometry, GeoJSON.GeoJsonProperties> | undefined;
  /**
   * 图层 id 前缀；省略时自动生成
   */
  layerId?: string | undefined;
  /**
   * 主色
   * @default "\"#22c55e\""
   */
  color?: string | undefined;
  /**
   * 扫描半径（像素）
   * @default "60"
   */
  radius?: number | undefined;
  /**
   * 旋转速度（度/秒）
   * @default "120"
   */
  speed?: number | undefined;
  /**
   * 插入到该图层之前
   */
  beforeId?: string | undefined;
}
```

## Changelog

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


## Sitemap

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