Track.LiveTrack
在线实时轨迹类,继承 Track.RoadLine 类。
构造函数
| 构造函数 | 描述 |
|---|---|
| new Track.LiveRoad(options: Track.liveTrackOptions) | 在线实时轨迹类,继承 Track.RoadLine 类。 |
Track.liveTrackOptions
实时轨迹配置参数,继承轨迹线基类参数 Track.trackLineOptions。
| 参数项 | 类型 | 描述 |
|---|---|---|
| duration | number | 【可选】间隔点时间,单位毫秒,默认 0 |
| guideStyle | Track.guideStyleOptions | 【可选】诱导线样式设置 |
| guidProperty | any | 【可选】诱导线属性 |
Track.guideStyleOptions
诱导线样式配置参数。
| 参数项 | 类型 | 描述 |
|---|---|---|
| style | Track.trackLineStyle | 【可选】回放展示时间,单位秒,默认 60 秒 |
| linearTexture | Array<[number,string]> | 【可选】颜色带,如果需要显示渐变色,此项必须设置 |
| gradientColor | number[] | 【可选】渐变颜色设置 |
属性
| 名称 | 类型 | 描述 |
|---|---|---|
| guidTrack | Track.LocalTrack|undefined | 诱导线对象 |
| guidStyle | Track.guideStyleOptions | 诱导线样式 |
| guidProperty | any | 诱导线属性 |
| guidTrackStatus | Track.GuidCodes | 【get/set】诱导线状态 |
方法
| 方法 | 返回 | 描述 |
|---|---|---|
| setGuidTrackPath(trackPath: Array<Track.TrackPoint>) | void | 设置诱导线轨迹点 |
| getGuidTrack() | Track.LocalTrack | 获取诱导轨迹 |
事件
| 事件标识 | 返回数据 | 描述 |
|---|---|---|
| Track.LineCodes.GUIDE_STATUS | {status: [Track.GuidCodes](/api/track-guid-codes)} | 诱导线状态 |
示例
ts
// 创建在线实时轨迹实例
const liveTrack = new Track.LiveTrack({
// 实时轨迹配置
duration: 1000, // 间隔点时间 1 秒
guideStyle: {
style: {
strokeColor: '#1869FF',
strokeWeight: 3,
strokeOpacity: 0.8
},
linearTexture: [
[0, '#ff0000'],
[0.5, '#00ff00'],
[1, '#0000ff']
],
gradientColor: [0xff0000, 0x00ff00, 0x0000ff]
},
guidProperty: {
name: '测试诱导线',
type: 'guide'
}
});
// 设置诱导线轨迹点
const trackPoints = [
new Track.TrackPoint({
position: new BMapGL.Point(116.404, 39.915),
time: Date.now()
}),
new Track.TrackPoint({
position: new BMapGL.Point(116.405, 39.916),
time: Date.now() + 1000
})
];
liveTrack.setGuidTrackPath(trackPoints);
// 获取诱导轨迹
const guidTrack = liveTrack.getGuidTrack();
// 监听诱导线状态变化
liveTrack.on(Track.LineCodes.GUIDE_STATUS, (args) => {
console.log('诱导线状态:', args.status);
});