Track.TrackPoint
轨迹点类。
构造函数
| 构造函数 | 描述 |
|---|---|
| new Track.TrackPoint(point: Point, options?: Track.trackPointOptions) | 轨迹点类。 |
属性
| 名称 | 类型 | 描述 |
|---|---|---|
| rotation | number|undefined | 旋转角 |
| timeStamp | number|undefined | 时间戳 |
Track.trackPointOptions
轨迹点类构造函数参数。
| 参数项 | 类型 | 描述 |
|---|---|---|
| rotation | number | 【可选】旋转角 |
| timeStamp | number | 【可选】时间戳 |
方法
| 方法 | 返回 | 描述 |
|---|---|---|
| setPoint(point: Point) | void | 设置点 |
| getPoint() | Point | 获取点 |
| getPointMC() | Point | 获取 mc 坐标点 |
| getPointMCArray() | [number, number] | 获取 mc 数组 |
| setRotation(val: number) | void | 设置旋转角 |
| getRotation() | number | undefined | 获取旋转角 |
| getTimeStamp() | number | undefined | 获取时间戳 |
| getOptions(key?: string) | any | 获取设置参数 |
| serialize() | any | 序列化 |
| static deserialize(data: any) | TrackPoint | undefined | 反序列化 |
| clone() | TrackPoint | 对象克隆 |
| on(type: string, callback: Function) | void | 监听事件 |
| fire(type: string, args: any) | void | 触发事件 |
| off(type: string, callback: Function) | void | 移除事件 |
示例
ts
// 创建轨迹点实例
const trackPoint = new Track.TrackPoint(
new BMapGL.Point(116.404, 39.915),
{
rotation: 90,
timeStamp: Date.now()
}
);
// 设置点
trackPoint.setPoint(new BMapGL.Point(116.405, 39.916));
// 获取点
const point = trackPoint.getPoint();
// 获取 mc 坐标点
const mcPoint = trackPoint.getPointMC();
// 获取 mc 数组
const mcArray = trackPoint.getPointMCArray();
// 设置旋转角
trackPoint.setRotation(180);
// 获取旋转角
const rotation = trackPoint.getRotation();
// 获取时间戳
const timeStamp = trackPoint.getTimeStamp();
// 获取设置参数
const options = trackPoint.getOptions();
// 序列化
const data = trackPoint.serialize();
// 反序列化
const newTrackPoint = Track.TrackPoint.deserialize(data);
// 克隆
const clonedTrackPoint = trackPoint.clone();