-
Notifications
You must be signed in to change notification settings - Fork 124
/
ClusterMarker.js
41 lines (33 loc) · 1.03 KB
/
ClusterMarker.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
'use-strict'
// base libs
import PropTypes from 'prop-types'
import React, { Component } from 'react'
export default class ClusterMarker extends Component {
constructor(props) {
super(props)
this.onPress = this.onPress.bind(this)
}
onPress() {
this.props.onPress(this.props)
}
render() {
const pointCount = this.props.properties.point_count // eslint-disable-line camelcase
const latitude = this.props.geometry.coordinates[1],
longitude = this.props.geometry.coordinates[0]
if (this.props.renderCluster) {
const cluster = {
pointCount,
coordinate: { latitude, longitude },
clusterId: this.props.properties.cluster_id,
}
return this.props.renderCluster(cluster, this.onPress)
}
throw "Implement renderCluster method prop to render correctly cluster marker!"
}
}
ClusterMarker.propTypes = {
renderCluster: PropTypes.func,
onPress: PropTypes.func.isRequired,
geometry: PropTypes.object.isRequired,
properties: PropTypes.object.isRequired,
}