---
title: "MaplibreLottieMarker"
description: "在标记位用 lottie-web 渲染矢量动画，支持 animationData 内联或 path 远程加载。"
canonical_url: "https://maplibre.mhaibaraai.cn/docs/core/lottie-marker"
---
# MaplibreLottieMarker

> 在标记位用 lottie-web 渲染矢量动画，支持 animationData 内联或 path 远程加载。

## 简介

`MaplibreLottieMarker` 在标记位置用 lottie-web 渲染矢量动画（基于 [MaplibreMarker](https://maplibre.mhaibaraai.cn/docs/core/marker) 的 DOM，而非 icon 帧驱动）。动画来源 `animationData`（内联 JSON）或 `path`（远程 URL）二选一，位置经 `v-model:lnglat` 绑定。

## 用法

传入内联 `animationData`，`width` / `height` 控制尺寸：

```vue [LottieMarkerExample.vue]
<script setup lang="ts">
import type { LngLatLike } from 'maplibre-gl'
import animationData from '~/assets/lottie/marker-pulse.json'

const position = ref<LngLatLike>([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 }">
      <MaplibreLottieMarker
        v-model:lnglat="position"
        :animation-data="animationData"
        :width="80"
        :height="80"
      />
    </MaplibreMap>
  </div>
</template>
```

## API

### Props

```ts
/**
 * Props for the MaplibreLottieMarker component
 */
interface MaplibreLottieMarkerProps {
  lnglat: LngLatLike;
  /**
   * lottie 动画数据（JSON 对象）；与 path 二选一，按引用比较，替换对象才重新加载
   */
  animationData?: object | undefined;
  /**
   * lottie 动画 URL；与 animationData 二选一
   */
  path?: string | undefined;
  /**
   * 是否循环
   * @default true
   */
  loop?: boolean | undefined;
  /**
   * 是否自动播放
   * @default true
   */
  autoplay?: boolean | undefined;
  /**
   * 播放速度倍率
   * @default 1
   */
  speed?: number | undefined;
  /**
   * 容器宽（像素）
   * @default 64
   */
  width?: number | undefined;
  /**
   * 容器高（像素）
   * @default 64
   */
  height?: number | undefined;
}
```

### Emits

```ts
/**
 * Emitted events for the MaplibreLottieMarker component
 */
interface MaplibreLottieMarkerEmits {
  update:lnglat: (payload: [value: LngLatLike]) => void;
}
```

## Changelog

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

---

- [lottie-web](https://github.com/airbnb/lottie-web)


## Sitemap

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