1- # React Native Map Clustering
21
3- Simple module that adds map clustering for both iOS and Android.
2+ # React Native Map Clustering
43
5-
6- ### Pre requirements:
7-
8- - Install 'react-native-maps' module. You can find all information here:
9- https://github.com/airbnb/react-native-maps
10-
11- In general all you have to do to start:
12-
13- ``` sh
14- npm install react-native-maps --save
15- react-native link react-native-maps
16- ```
17- - Minimum versions you need for this module:
18-
19- react: >=16.0
20- react-native >=0.40
21- react-native-maps >=0.15.0
4+ React Native module that handles map clustering for you.
5+ Works with ** Expo** and ** react-native-cli** .
226
237### Installation
24- All you have to do:
25- ``` sh
8+ ``` js
9+ // only if you haven't installed it before
10+ npm install react- native- maps -- save
11+ //
2612npm install react- native- map- clustering -- save
2713```
2814### Usage
2915
30- Usage is very simple:
31- 1 . Import MapView
16+ 1 . Import Components
3217``` javascript
3318import MapView from ' react-native-map-clustering' ;
34- ```
35- - Import Marker
36- ``` javascript
3719import { Marker } from ' react-native-maps' ;
3820```
39- 2 . Add this to your render method (you can put your own markers and region):
21+
22+ 2 . In ** render()** method add this:
23+
4024``` javascript
41- < MapView
42- region= {{latitude: 52.5 , longitude: 19.2 ,
43- latitudeDelta: 8.5 , longitudeDelta: 8.5 }}
44- style= {{width: mapWidth, height: mapHeight}}>
45- < Marker coordinate= {{latitude: 52.0 , longitude: 18.2 }} / >
46- < Marker coordinate= {{latitude: 52.4 , longitude: 18.7 }} / >
47- < Marker coordinate= {{latitude: 52.1 , longitude: 18.4 }} / >
48- < Marker coordinate= {{latitude: 52.6 , longitude: 18.3 }} / >
49- < Marker coordinate= {{latitude: 51.6 , longitude: 18.0 }} / >
50- < Marker coordinate= {{latitude: 53.1 , longitude: 18.8 }} / >
51- < Marker coordinate= {{latitude: 52.9 , longitude: 19.4 }} / >
25+ < MapView
26+ region= {{
27+ latitude: 52.5 ,
28+ longitude: 19.2 ,
29+ latitudeDelta: 8.5 ,
30+ longitudeDelta: 8.5
31+ }}
32+ style= {{ width: 400 , height: 800 }}
33+ >
34+ < Marker coordinate= {{ latitude: 52.0 , longitude: 18.2 }} / >
35+ < Marker coordinate= {{ latitude: 52.4 , longitude: 18.7 }} / >
36+ < Marker coordinate= {{ latitude: 52.1 , longitude: 18.4 }} / >
37+ < Marker coordinate= {{ latitude: 52.6 , longitude: 18.3 }} / >
38+ < Marker coordinate= {{ latitude: 51.6 , longitude: 18.0 }} / >
39+ < Marker coordinate= {{ latitude: 53.1 , longitude: 18.8 }} / >
40+ < Marker coordinate= {{ latitude: 52.9 , longitude: 19.4 }} / >
41+ < Marker coordinate= {{ latitude: 52.2 , longitude: 21 }} / >
5242< / MapView>
5343```
54- 3 . ** That's all!** .
5544
5645### Demo
5746![ Alt Text] ( https://raw.githubusercontent.com/venits/react-native-map-clustering/master/demo.gif )
5847
5948
60- ### Extra props to control your clustering
6149## MapView
6250----
6351| Name | Type | Default | Note |
@@ -67,7 +55,7 @@ import { Marker } from 'react-native-maps';
6755| clusterTextColor | String | #FF5252 | Color of text in cluster. |
6856| clusterBorderColor | String | #FF5252 | Color of border. Set to transparent if you don't want borders. |
6957| clusterBorderWidth | Int | 1 | Width of border. Set to 0 if you don't want borders. |
70- | customDefinedMarker | Component | null | Define a custom react component that is used to render the cluster markers. |
58+ | customDefinedMarker | Marker | null | Define a custom react component that is used to render the cluster markers. |
7159| onClusterPress | Function | null | Allows you to control cluster on click event. Function returns coordinate of cluster. |
7260
7361## Marker
@@ -79,15 +67,20 @@ import { Marker } from 'react-native-maps';
7967Example of using props:
8068``` javascript
8169< MapView
82- clustering = {true }
8370 clusterColor = ' #000'
8471 clusterTextColor = ' #fff'
8572 clusterBorderColor = ' #fff'
8673 clusterBorderWidth = {4 }
74+ style= {{width: 400 , height: 800 }}
8775 region= {{latitude: 52.5 , longitude: 19.2 ,
8876 latitudeDelta: 8.5 , longitudeDelta: 8.5 }}
89- style= {{width: mapWidth, height: mapHeight}}>
90- < Marker coordinate= {{latitude: 52 , longitude: 19 }} cluster= {false } / >
77+ >
78+ < Marker
79+ coordinate= {{latitude: 52 , longitude: 19 }}
80+ cluster= {false }
81+ / >
82+ < Marker coordinate= {{latitude: 52 , longitude: 19 }} / >
9183< / MapView>
9284```
9385
86+
0 commit comments