MapboxTrail
动态轨迹,line-gradient 彗尾沿线循环平移。
简介
MapboxTrail 在线要素上渲染动态轨迹:line-gradient 彗尾窗口沿线循环平移(source 自动开启 lineMetrics);color / lineWidth / trailLength / duration / baseLine 控制外观与节奏。
用法
切换主色查看彗尾沿线流动:
<script setup lang="ts">
import type { FeatureCollection } from 'geojson'
withDefaults(defineProps<{ color?: string }>(), {
color: '#8b5cf6'
})
const data: FeatureCollection = {
type: 'FeatureCollection',
features: [
{
type: 'Feature',
properties: {},
geometry: {
type: 'LineString',
coordinates: [
[116.3, 39.9],
[116.4, 39.94],
[116.5, 39.91],
[116.46, 39.85],
[116.36, 39.87]
]
}
}
]
}
</script>
<template>
<div class="h-115 w-full overflow-hidden rounded-(--ui-radius) border border-default">
<MapboxMap
:options="{ style: 'mapbox://styles/mapbox/dark-v11', center: [116.41, 39.9], zoom: 11 }"
>
<MapboxTrail :data="data" :color="color" />
</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) | |
layerId | string图层 id 前缀;省略时自动生成 | |
color | '#8b5cf6' | string主色 |
lineWidth | 4 | number线宽(像素) |
trailLength | 0.25 | number彗尾长度(line-progress 占比 0-1) |
duration | 3000 | number跑完全程的周期(毫秒) |
beforeId | string插入到该图层之前 | |
baseLine | true | boolean是否同时绘制半透明底线 |
Changelog
No recent changes