ImageLottieLoader
ImageLottieLoader provides preloaded Lottie animation icons
Example
Example Source Code
vue
<template>
<div style="height: 400px" class="vw-full vh-full">
<mb-map :center="[115.124368, 29.216049]" :zoom="10">
<mb-tianditu-layer :types="tiandituTypes" />
<mb-image-lottie-loader :images="images" />
<mb-symbol-layer
id="symbol"
:data="symbolDataSource"
:icon-size="0.8"
icon-image-field="icon"
icon-rotation-alignment="map"
/>
</mb-map>
</div>
</template>
<script setup lang="ts">
import lottie from 'lottie-web/build/player/lottie_canvas'
import animData from './even-handling-icon.json'
animData.assets.forEach((a) => {
a.u = `${__RESOURCE_URL__}images/处置中/`
})
const tiandituTypes = ['vec', 'cia']
const images = [
{
name: 'lottieIcon',
size: [140, 100],
onAdd(context) {
lottie.loadAnimation({
renderer: 'canvas',
loop: true,
autoplay: true,
animationData: animData, // JSON文件路径
rendererSettings: {
context, // the canvas context, only support "2d" context
// preserveAspectRatio: 'xMinYMin slice', // Supports the same options as the svg element's preserveAspectRatio property
clearCanvas: true,
},
})
},
},
]
const symbolDataSource = [
{
coordinates: [115.124368, 29.216049],
properties: {
icon: 'lottieIcon',
},
},
{
coordinates: [115.124368, 29.246049],
properties: {
icon: 'lottieIcon',
},
},
{
coordinates: [115.124368, 29.186049],
properties: {
icon: 'lottieIcon',
},
},
{
coordinates: [115.324368, 29.216049],
properties: {
icon: 'lottieIcon',
},
},
]
</script>
API
PROPS
Name | Description | Type | Default |
---|---|---|---|
images | An array of image properties. Each object in the array must include a required name property and image-related information | Array<{ name: string; size: number[], onAdd: (context: CanvasRenderingContext2D) => void }> | - |
- You need to add the Lottie animation to the context (CanvasRenderingContext2D) within the onAdd method.
- size is a required property.
EVENTS
Name | Description | Parameters |
---|---|---|
created | Map initialization completed event | - |
SLOTS
Name | Description |
---|
METHODS
Name | Description | Definition |
---|