3
3
// base libs
4
4
import PropTypes from 'prop-types'
5
5
import React , { Component } from 'react'
6
- import { Marker } from 'react-native-maps'
7
- import { Text , View , StyleSheet } from 'react-native'
8
6
9
7
export default class ClusterMarker extends Component {
10
8
constructor ( props ) {
@@ -18,7 +16,6 @@ export default class ClusterMarker extends Component {
18
16
}
19
17
20
18
render ( ) {
21
-
22
19
const pointCount = this . props . properties . point_count // eslint-disable-line camelcase
23
20
const latitude = this . props . geometry . coordinates [ 1 ] ,
24
21
longitude = this . props . geometry . coordinates [ 0 ]
@@ -32,79 +29,13 @@ export default class ClusterMarker extends Component {
32
29
return this . props . renderCluster ( cluster , this . onPress )
33
30
}
34
31
35
- // keep default marker for backward compatibility, but it'll soon be deprecated
36
- console . warn ( 'Deprecation notice: default markers will soon be deprecated. Please, start using "renderCluster" prop.' ) // eslint-disable-line
37
-
38
- let scaleUpRatio = this . props . scaleUpRatio ? this . props . scaleUpRatio ( pointCount ) : ( 1 + ( Math . min ( pointCount , 999 ) / 100 ) )
39
- if ( isNaN ( scaleUpRatio ) ) {
40
- console . warn ( 'scaleUpRatio must return a Number, falling back to default' ) // eslint-disable-line
41
- scaleUpRatio = 1 + ( Math . min ( pointCount , 999 ) / 100 )
42
- }
43
-
44
- let textForCluster = '1'
45
-
46
- let width = Math . floor ( this . props . clusterInitialDimension * scaleUpRatio ) ,
47
- height = Math . floor ( this . props . clusterInitialDimension * scaleUpRatio ) ,
48
- fontSize = Math . floor ( this . props . clusterInitialFontSize * scaleUpRatio ) ,
49
- borderRadius = Math . floor ( width / 2 )
50
-
51
- // cluster dimension upper limit
52
- width = width <= ( this . props . clusterInitialDimension * 2 ) ? width : this . props . clusterInitialDimension * 2
53
- height = height <= ( this . props . clusterInitialDimension * 2 ) ? height : this . props . clusterInitialDimension * 2
54
- fontSize = fontSize <= 18 ? fontSize : 18
55
-
56
- if ( pointCount >= 2 && pointCount <= 10 ) {
57
- textForCluster = pointCount . toString ( )
58
- } else if ( pointCount > 10 && pointCount <= 25 ) {
59
- textForCluster = '10+'
60
- } else if ( pointCount > 25 && pointCount <= 50 ) {
61
- textForCluster = '25+'
62
- } else if ( pointCount > 50 && pointCount <= 100 ) {
63
- textForCluster = '50+'
64
- } else if ( pointCount > 100 ) {
65
- textForCluster = '100+'
66
- }
67
-
68
- const { containerStyle, textStyle } = this . props
69
-
70
- return (
71
- < Marker coordinate = { { latitude, longitude } } onPress = { this . onPress } >
72
- < View style = { [ styles . container , containerStyle , { width, height, borderRadius } ] } >
73
- < Text style = { [ styles . counterText , textStyle , { fontSize } ] } > { textForCluster } </ Text >
74
- </ View >
75
- </ Marker >
76
- )
32
+ throw "Implement renderCluster method prop to render correctly cluster marker!"
77
33
}
78
34
}
79
35
80
- ClusterMarker . defaultProps = {
81
- textStyle : { } ,
82
- containerStyle : { }
83
- }
84
-
85
36
ClusterMarker . propTypes = {
86
- scaleUpRatio : PropTypes . func ,
87
37
renderCluster : PropTypes . func ,
88
38
onPress : PropTypes . func . isRequired ,
89
39
geometry : PropTypes . object . isRequired ,
90
- textStyle : PropTypes . object . isRequired ,
91
40
properties : PropTypes . object . isRequired ,
92
- containerStyle : PropTypes . object . isRequired ,
93
- clusterInitialFontSize : PropTypes . number . isRequired ,
94
- clusterInitialDimension : PropTypes . number . isRequired ,
95
41
}
96
-
97
- const styles = StyleSheet . create ( {
98
- container : {
99
- borderWidth : 1 ,
100
- alignItems : 'center' ,
101
- borderColor : '#65bc46' ,
102
- justifyContent : 'center' ,
103
- backgroundColor : '#fff'
104
- } ,
105
- counterText : {
106
- fontSize : 16 ,
107
- color : '#65bc46' ,
108
- fontWeight : '400'
109
- }
110
- } )
0 commit comments