---
title: "MapboxAnimatedImage"
description: "Animated image icons decoding GIF/APNG/WebP via ImageDecoder and looping per-frame on symbol features."
canonical_url: "https://mapbox.mhaibaraai.cn/en/docs/effects/animated-image"
---
# MapboxAnimatedImage

> Animated image icons decoding GIF/APNG/WebP via ImageDecoder and looping per-frame on symbol features.

## Introduction

`MapboxAnimatedImage` uses `ImageDecoder` to decode GIF / APNG / WebP / AVIF animated images into frames, driving a symbol layer to loop frame-by-frame at each frame's native duration — no decoding dependencies required; `size` normalizes the frame dimensions, and `fps` is the fallback frame rate when no native frame duration is available.

## Usage

Load the Mapbox example radar GIF and loop the animation:

```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](https://mapbox.mhaibaraai.cn/sitemap.md) for all pages.
