Methods
(async, static) append(dot) → {Promise}
添加一个点
Parameters:
| Name | Type | Description |
|---|---|---|
dot |
待添加的点对象 |
Returns:
新添加点的索引,小于0失败
- Type
- Promise
(async, static) appendDots(dots) → {Promise}
将另一个Dots的点添加到尾端
Parameters:
| Name | Type | Description |
|---|---|---|
dots |
待添加的点序列对象 |
Returns:
大于0成功,否则失败
- Type
- Promise
(async, static) clear() → {Promise}
清空
Returns:
大于0成功,否则失败
- Type
- Promise
(async, static) createObj() → {Promise.<Dots>}
构造一个新的 Dots 对象。
Returns:
- Type
- Promise.<Dots>
(async, static) fromObjectArray(objArray) → {Number}
通过包含多个对象的数组,给Dots设置点
Parameters:
| Name | Type | Description |
|---|---|---|
objArray |
Array | 包含一系列对象的数组,对象形式{x: Number, y: Number} |
Returns:
大于0成功,否则失败
- Type
- Number
Example
let array = [];
array.push({x: 114.63, y: 30.40});
array.push({x: 114.33, y: 30.24});
array.push({x: 114.22, y: 30.22});
array.push({x: 114.15, y: 30.66});
let dotsModule = new Dots();
let dots = await dotsModule.createObj();
await dots.fromObjectArray(array);
(async, static) get(index) → {Promise.<Dot>}
返回索引处的点
Parameters:
| Name | Type | Description |
|---|---|---|
index |
待查找的索引号 |
Returns:
索引处的点
- Type
- Promise.<Dot>
(static) isValid() → {Boolean}
判断Dots对象是否有效
Returns:
true:有效;false:无效
- Type
- Boolean
(async, static) remove(index) → {Promise}
删除索引处的点
Parameters:
| Name | Type | Description |
|---|---|---|
index |
待删除的点索引 |
Returns:
大于0成功,否则失败
- Type
- Promise
(async, static) size() → {Promise}
获取X坐标
Returns:
折线点数
- Type
- Promise
(async, static) toObjectArray() → {Array}
返回Dots的一系列点坐标构成的对象数组
Returns:
返回包含由点坐标构成的对象的数组,对象形式{x: Number, y: Number}
- Type
- Array