VideoMp4Loader
Environment: HTTPS & modern browser support
VideoMp4Loader provides preloaded MP4 icons
Example
Example Source Code
tsx
import React, { useEffect, useRef, useState } from 'react'
import ReactDOM from 'react-dom'
import {
MbMap,
MbSymbolLayer,
MbTiandituLayer,
MbVideoMp4Loader,
} from '@mapbox-react/core'
const App = () => {
const [mapCenter] = useState([115.124368, 29.216049])
const [zoom, setZoom] = useState(10)
const symbolDataSource = [
{
coordinates: [115.124368, 29.216049],
properties: {
icon: 'rain',
},
},
{
coordinates: [115.324368, 29.216049],
properties: {
icon: 'rain',
},
},
]
const videos = [
{
name: 'rain',
url: `https://mapbox-web.github.io/mapbox-react/videos/rains-s.mp4`,
size: [54, 96],
},
]
return (
<div className="map-wrapper">
<MbMap center={mapCenter} zoom={zoom}>
<MbVideoMp4Loader videos={videos} />
<MbTiandituLayer types={['vec']} />
<MbSymbolLayer
data={symbolDataSource}
iconImageField="icon"
iconSize={1.5}
iconAllowOverlap
textAllowOverlap
/>
</MbMap>
</div>
)
}
ReactDOM.render(<App />, document.querySelector('#root'))
API
PROPS
Name | Description | Type | Default |
---|---|---|---|
videos | An array of image properties. Each object in the array must include a required name property and image-related information | array<{ name: string; url: string, size?: number[], requestInit?: RequestInit }> | - |
This component uses fetch to request image data. If the request is cross-origin, please configure CORS headers on the server side. requestInit refers to the second parameter of the fetch function.
EVENTS
Name | Description | Parameters |
---|---|---|
onCreated | Map initialization completed event | - |
METHODS
Name | Description | Definition |
---|