Polyline.js
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// @flow
import React, { PureComponent } from "react";
import PropTypes from "prop-types";
import {
ColorPropType,
Platform,
processColor,
requireNativeComponent,
ViewPropTypes
} from "react-native";
import { LatLng } from "../PropTypes";
export default class Polyline extends PureComponent {
static propTypes = {
...ViewPropTypes,
/**
* 节点坐标
*/
coordinates: PropTypes.arrayOf(LatLng).isRequired,
/**
* 线段宽度
*/
width: PropTypes.number,
/**
* 线段颜色
*/
color: ColorPropType,
/**
* 层级
*/
zIndex: PropTypes.number,
/**
* 多段颜色
*/
colors: PropTypes.arrayOf(ColorPropType),
/**
* 是否使用颜色渐变
*/
gradient: PropTypes.bool,
/**
* 是否绘制大地线
*/
geodesic: PropTypes.bool,
/**
* 是否绘制虚线
*/
dashed: PropTypes.bool,
/**
* 点击事件
*/
onPress: PropTypes.func
};
static defaultProps = {
colors: []
};
render() {
const props = {
...this.props,
...Platform.select({
android: {
colors: this.props.colors.map(processColor)
}
})
};
return <AMapPolyline {...props} />;
}
}
const AMapPolyline = requireNativeComponent("AMapPolyline", Polyline);