forked from felixgourdeau/ScaleBar
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
59 lines (52 loc) · 1.41 KB
/
index.js
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
// @flow
import React, { Component } from "react";
import ScaleBarView from "./src/ScaleBarView";
import { getScaleBarInfoFromZoomLevel } from "./src/ScaleBarModel";
import { LIMIT_SIZE, LINE_COLOR, LINE_SIZE } from "./src/constants";
type Props = {
zoom: number,
latitude: number,
bottom: number,
left: number,
metersOnly: boolean,
color: string,
lineWidth: number,
fontSize: number,
limiterHeight: number
};
class ScaleBar extends Component<Props> {
static defaultProps = {
latitude: 48.81879736812265,
bottom: 42,
left: 10,
metersOnly: false,
color: LINE_COLOR,
lineWidth: LINE_SIZE,
fontSize: 11,
limiterHeight: LIMIT_SIZE
};
render() {
const {
scaleBarSizeInMeters,
scaleBarTextInMeters,
scaleBarSizeInFeet,
scaleBarTextInFeet
} = getScaleBarInfoFromZoomLevel(this.props.zoom, this.props.latitude);
return (
<ScaleBarView
padding_left={this.props.left}
padding_bottom={this.props.bottom}
lengthMeter={scaleBarSizeInMeters}
lengthFeet={scaleBarSizeInFeet}
scaleTextMeters={scaleBarTextInMeters}
scaleTextFeet={scaleBarTextInFeet}
metersOnly={this.props.metersOnly}
color={this.props.color}
lineWidth={this.props.lineWidth}
limiterHeight={this.props.limiterHeight}
fontSize={this.props.fontSize}
/>
);
}
}
export default ScaleBar;