File tree Expand file tree Collapse file tree 2 files changed +21
-24
lines changed Expand file tree Collapse file tree 2 files changed +21
-24
lines changed Original file line number Diff line number Diff line change 7
7
isMarker ,
8
8
markerToGeoJSONFeature ,
9
9
calculateBBox ,
10
- returnMapZoom
10
+ returnMapZoom ,
11
+ generateSpiral
11
12
} from "./helpers" ;
12
13
13
14
const ClusteredMapView = ( {
@@ -86,6 +87,7 @@ const ClusteredMapView = ({
86
87
let positions = generateSpiral (
87
88
markers [ 0 ] . properties . point_count ,
88
89
markers [ 0 ] . geometry . coordinates ,
90
+ clusterChildren ,
89
91
) ;
90
92
updateSpiderMarker ( positions ) ;
91
93
updateSpiderfierMarker ( {
@@ -97,29 +99,6 @@ const ClusteredMapView = ({
97
99
}
98
100
} , [ isSpiderfier ] ) ;
99
101
100
- /**
101
- * To generate coordinates in spiral way
102
- * @param count Number of coordinates you want
103
- * @param centerLocation center location
104
- */
105
- const generateSpiral = ( count , centerLocation ) => {
106
- let res = [ ] ;
107
- res . length = count ;
108
- let angle = 0 ;
109
- for ( let i = 0 ; i < count ; i ++ ) {
110
- angle = 0.1 * ( i * 0.5 ) ;
111
- let latitude = centerLocation [ 1 ] + 0.00025 * angle * Math . cos ( angle ) ;
112
- let longitude = centerLocation [ 0 ] + 0.00025 * angle * Math . sin ( angle ) ;
113
- res [ i ] = {
114
- longitude,
115
- latitude,
116
- image : clusterChildren [ i ] . properties . image ,
117
- onPress : clusterChildren [ i ] . properties . onPress ,
118
- } ;
119
- }
120
- return res ;
121
- } ;
122
-
123
102
const _onRegionChangeComplete = region => {
124
103
if ( superCluster ) {
125
104
const bBox = calculateBBox ( region ) ;
Original file line number Diff line number Diff line change @@ -49,6 +49,24 @@ export const markerToGeoJSONFeature = (marker, index) => {
49
49
} ;
50
50
} ;
51
51
52
+ export const generateSpiral = ( count , centerLocation , clusterChildren ) => {
53
+ let res = [ ] ;
54
+ res . length = count ;
55
+ let angle = 0 ;
56
+ for ( let i = 0 ; i < count ; i ++ ) {
57
+ angle = 0.1 * ( i * 0.5 ) ;
58
+ let latitude = centerLocation [ 1 ] + 0.00025 * angle * Math . cos ( angle ) ;
59
+ let longitude = centerLocation [ 0 ] + 0.00025 * angle * Math . sin ( angle ) ;
60
+ res [ i ] = {
61
+ longitude,
62
+ latitude,
63
+ image : clusterChildren [ i ] . properties . image ,
64
+ onPress : clusterChildren [ i ] . properties . onPress ,
65
+ } ;
66
+ }
67
+ return res ;
68
+ } ;
69
+
52
70
export const returnMarkerStyle = points => {
53
71
if ( points >= 50 ) {
54
72
return {
You can’t perform that action at this time.
0 commit comments