---
title: "MaplibreSpriteImage"
description: "Sprite-sheet frame animation icons sliced from one image and looped per frame on symbol features."
canonical_url: "https://maplibre.mhaibaraai.cn/en/docs/effects/sprite-image"
---
# MaplibreSpriteImage

> Sprite-sheet frame animation icons sliced from one image and looped per frame on symbol features.

## Introduction

`MaplibreSpriteImage` slices a sprite sheet (row-major multi-frame layout) into individual frames and registers them as a frame-driven icon, looped per frame on a symbol layer with no decoding dependencies; `frames` / `columns` / `rows` / `frameWidth` / `frameHeight` / `fps` / `size` control the slicing and playback.

## Usage

Load an 18-frame sprite sheet and loop the animation:

```vue [SpriteImageExample.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: 13 }">
      <!-- Phaser 公开雪碧图：18 帧 37×45 单行 -->
      <MaplibreSpriteImage
        :data="data"
        image="https://labs.phaser.io/assets/sprites/metalslug_mummy37x45.png"
        :frames="18"
        :columns="18"
        :frame-width="37"
        :frame-height="45"
        :fps="12"
        :size="90"
      />
    </MaplibreMap>
  </div>
</template>
```

## API

### Props

```ts
/**
 * Props for the MaplibreSpriteImage component
 */
interface MaplibreSpriteImageProps {
  /**
   * 点要素数据（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（所有帧拼一张图，行优先排布）
   */
  image: string;
  /**
   * 总帧数
   */
  frames: number;
  /**
   * 列数；省略时等于 frames（单行）
   */
  columns?: number | undefined;
  /**
   * 行数
   * @default 1
   */
  rows?: number | undefined;
  /**
   * 单帧宽（像素）；省略由图宽/列数推算
   */
  frameWidth?: number | undefined;
  /**
   * 单帧高（像素）；省略由图高/行数推算
   */
  frameHeight?: number | undefined;
  /**
   * 播放帧率（帧/秒）
   * @default 12
   */
  fps?: number | undefined;
  /**
   * 上图图标边长（像素）
   * @default 64
   */
  size?: number | undefined;
  /**
   * 图层 id；省略时自动生成，变更需配合 `:key` 重建
   */
  layerId?: string | undefined;
  /**
   * 插入到该图层之前
   */
  beforeId?: string | undefined;
}
```

## Changelog

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


## Sitemap

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