---
title: "MapboxAnimatedImage"
description: "动图图标层，ImageDecoder 解码 GIF/APNG/WebP 为帧逐帧循环播放。"
seo_title: "MapboxAnimatedImage Component"
seo_description: "Animated image icons decoding GIF/APNG/WebP via ImageDecoder and looping per-frame on symbol features."
canonical_url: "https://mapbox.mhaibaraai.cn/docs/effects/animated-image"
---
# MapboxAnimatedImage

> 动图图标层，ImageDecoder 解码 GIF/APNG/WebP 为帧逐帧循环播放。

## 简介

`MapboxAnimatedImage` 用 `ImageDecoder` 把 GIF / APNG / WebP / AVIF 动图解码为帧，按各帧时长驱动 symbol 逐帧循环播放，零解码依赖；`size` 统一帧尺寸，`fps` 为无原生帧时长时的回退帧率。

## 用法

加载 Mapbox 示例雷达动图并循环播放：

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

const data: FeatureCollection = {
  type: 'FeatureCollection',
  features: [
    { type: 'Feature', properties: {}, geometry: { type: 'Point', coordinates: [116.397, 39.908] } }
  ]
}
</script>

<template>
  <div class="h-115 w-full overflow-hidden rounded-(--ui-radius) border border-default">
    <MapboxMap :options="{ style: 'mapbox://styles/mapbox/light-v11', center: [116.397, 39.908], zoom: 12 }">
      <!-- 自托管多帧动图（docs/public，同源无 CORS） -->
      <MapboxAnimatedImage
        :data="data"
        image="/animated-marker.gif"
        :size="64"
      />
    </MapboxMap>
  </div>
</template>
```

## API

### Props

```ts
/**
 * Props for the MapboxAnimatedImage component
 */
interface MapboxAnimatedImageProps {
  /**
   * 点要素数据（GeoJSON 或其 URL）
   */
  data: string | GeoJSON.GeoJSON<GeoJSON.Geometry, GeoJSON.GeoJsonProperties> | undefined;
  /**
   * 动图 URL（GIF/APNG/WebP/AVIF）
   */
  image: string;
  /**
   * 图标边长（像素），帧统一缩放到 size×size
   * @default "64"
   */
  size?: number | undefined;
  /**
   * 解码无原生帧时长时的回退帧率
   * @default "12"
   */
  fps?: number | undefined;
  /**
   * 图层 id；省略时自动生成
   */
  layerId?: string | undefined;
  /**
   * 插入到该图层之前
   */
  beforeId?: string | undefined;
}
```

## Changelog

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


## Sitemap

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