forked from novalabio/react-native-maps-super-cluster
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathClusterMarker.js
33 lines (28 loc) · 956 Bytes
/
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
// base libs
import React from 'react';
import PropTypes from 'prop-types';
export default class ClusterMarker extends React.PureComponent {
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];
const 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,
};