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
|
import React from 'react'
import { PigeonProps } from '../types'
interface ZoomProps extends PigeonProps {
style?: React.CSSProperties
buttonStyle?: React.CSSProperties
}
const commonStyle: React.CSSProperties = {
position: 'absolute',
top: 10,
left: 10,
}
const commonButtonStyle: React.CSSProperties = {
width: 28,
height: 28,
borderRadius: 2,
boxShadow: '0 1px 4px -1px rgba(0,0,0,.3)',
background: 'white',
lineHeight: '26px',
fontSize: '20px',
fontWeight: 700,
color: '#666',
marginBottom: 1,
cursor: 'pointer',
border: 'none',
display: 'block',
outline: 'none',
}
export function ZoomControl({ style, buttonStyle, setCenterZoom, mapState, mapProps }: ZoomProps): JSX.Element {
return (
<div className="pigeon-zoom-buttons pigeon-drag-block" style={style ? { ...commonStyle, ...style } : commonStyle}>
<button
className="pigeon-zoom-in"
type="button"
style={buttonStyle ? { ...commonButtonStyle, ...buttonStyle } : commonButtonStyle}
onClick={() => setCenterZoom(mapState.center, Math.min(mapState.zoom + 1, mapProps.maxZoom))}
>
+
</button>
<button
className="pigeon-zoom-out"
type="button"
style={buttonStyle ? { ...commonButtonStyle, ...buttonStyle } : commonButtonStyle}
onClick={() => setCenterZoom(mapState.center, Math.max(mapState.zoom - 1, mapProps.minZoom))}
>
–
</button>
</div>
)
}
|