MapboxAnimatedImage
动图图标层,ImageDecoder 解码 GIF/APNG/WebP 为帧逐帧循环播放。
简介
MapboxAnimatedImage 用 ImageDecoder 把 GIF / APNG / WebP / AVIF 动图解码为帧,按各帧时长驱动 symbol 逐帧循环播放,零解码依赖;size 统一帧尺寸,fps 为无原生帧时长时的回退帧率。
用法
加载 Mapbox 示例雷达动图并循环播放:
<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
| Prop | Default | Type |
|---|---|---|
data | string | GeoJSON.Point | GeoJSON.MultiPoint | GeoJSON.LineString | GeoJSON.MultiLineString | GeoJSON.Polygon | GeoJSON.MultiPolygon | GeoJSON.GeometryCollection<GeoJSON.Geometry> | GeoJSON.Feature<GeoJSON.Geometry, { [name: string]: any; }> | GeoJSON.FeatureCollection<GeoJSON.Geometry, { [name: string]: any; }>点要素数据(GeoJSON 或其 URL) | |
image | string动图 URL(GIF/APNG/WebP/AVIF) | |
size | 64 | number图标边长(像素),帧统一缩放到 size×size |
fps | 12 | number解码无原生帧时长时的回退帧率 |
layerId | string图层 id;省略时自动生成 | |
beforeId | string插入到该图层之前 |
Changelog
No recent changes