---
title: "MaplibreAnimatedImage"
description: "动图图标层，ImageDecoder 解码 GIF/APNG/WebP 为帧逐帧循环播放。"
canonical_url: "https://maplibre.mhaibaraai.cn/docs/effects/animated-image"
---
# MaplibreAnimatedImage

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

## 简介

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

## 用法

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

```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">
    <MaplibreMap :options="{ style: 'https://tiles.openfreemap.org/styles/positron', center: [116.397, 39.908], zoom: 12 }">
      <!-- 自托管多帧动图（docs/public，同源无 CORS） -->
      <MaplibreAnimatedImage
        :data="data"
        image="/animated-marker.gif"
        :size="64"
      />
    </MaplibreMap>
  </div>
</template>
```

## API

### Props

```ts
/**
 * Props for the MaplibreAnimatedImage component
 */
interface MaplibreAnimatedImageProps {
  /**
   * 点要素数据（GeoJSON 或其 URL）
   */
  data: string | GeoJSON.Point | GeoJSON.MultiPoint | GeoJSON.LineString | GeoJSON.MultiLineString | GeoJSON.Polygon | GeoJSON.MultiPolygon | GeoJSON.GeometryCollection<GeoJSON.Geometry> | GeoJSON.Feature<GeoJSON.Geometry, GeoJSON.GeoJsonProperties> | GeoJSON.FeatureCollection<GeoJSON.Geometry, GeoJSON.GeoJsonProperties>;
  /**
   * 动图 URL（GIF/APNG/WebP/AVIF）
   */
  image: string;
  /**
   * 图标边长（像素），帧统一缩放到 size×size
   * @default 64
   */
  size?: number | undefined;
  /**
   * 解码无原生帧时长时的回退帧率
   * @default 12
   */
  fps?: number | undefined;
  /**
   * 图层 id；省略时自动生成，变更需配合 `:key` 重建
   */
  layerId?: string | undefined;
  /**
   * 插入到该图层之前
   */
  beforeId?: string | undefined;
}
```

## Changelog

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


## Sitemap

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